Class: TT::SimpleTask
- Inherits:
-
Object
- Object
- TT::SimpleTask
- Defined in:
- TT_Lib2/simpletask.rb
Overview
Instance Method Summary collapse
-
#initialize(task_name, collection, model = nil, decimals_places = 1) ⇒ SimpleTask
constructor
A new instance of SimpleTask.
- #run ⇒ Nil
Constructor Details
#initialize(task_name, collection, model = nil, decimals_places = 1) ⇒ SimpleTask
Returns a new instance of SimpleTask
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'TT_Lib2/simpletask.rb', line 37 def initialize( task_name, collection, model=nil, decimals_places=1 ) unless collection.is_a?( Enumerable ) raise ArgumentError, 'collection argument must be Enumerable' end if model && !model.is_a?( Sketchup::Model ) raise ArgumentError, 'model argument must be Sketchup::Model or nil' end @task_name = task_name @collection = collection @model = model @decimals_places = decimals_places end |
Instance Method Details
#run ⇒ Nil
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'TT_Lib2/simpletask.rb', line 52 def run if @model TT::Model.start_operation( @task_name, @model ) end progress = TT::Progressbar.new( @collection, @task_name, @decimals_places ) for item in @collection yield( item ) progress.next end if @model @model.commit_operation end Sketchup.status_text = "#{@task_name} complete! (#{progress.elapsed_time(true)})" nil rescue => e if @model @model.abort_operation end #raise e puts e. puts e.backtrace.join("\n") #UI.messagebox("#{e.message}\n\n#{e.backtrace.join("\n")}", MB_MULTILINE) end |