Class: ArrayProgressItem
- Inherits:
-
Object
- Object
- ArrayProgressItem
- Defined in:
- lib/array_with_progress/array_progress_item.rb
Instance Attribute Summary collapse
-
#extra_name ⇒ Object
Returns the value of attribute extra_name.
-
#item ⇒ Object
Returns the value of attribute item.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#progress ⇒ Object
Returns the value of attribute progress.
-
#status ⇒ Object
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#extra_name ⇒ Object
Returns the value of attribute extra_name.
8 9 10 |
# File 'lib/array_with_progress/array_progress_item.rb', line 8 def extra_name @extra_name end |
#item ⇒ Object
Returns the value of attribute item.
6 7 8 |
# File 'lib/array_with_progress/array_progress_item.rb', line 6 def item @item end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/array_with_progress/array_progress_item.rb', line 8 def name @name end |
#parent ⇒ Object
Returns the value of attribute parent.
5 6 7 |
# File 'lib/array_with_progress/array_progress_item.rb', line 5 def parent @parent end |
#progress ⇒ Object
Returns the value of attribute progress.
8 9 10 |
# File 'lib/array_with_progress/array_progress_item.rb', line 8 def progress @progress end |
#status ⇒ Object
Returns the value of attribute status.
8 9 10 |
# File 'lib/array_with_progress/array_progress_item.rb', line 8 def status @status end |
Class Method Details
.run!(parent_, item_, progress_, &block) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/array_with_progress/array_progress_item.rb', line 10 def self.run!(parent_, item_, progress_, &block) pi = ArrayProgressItem.new pi.parent = parent_ pi.item = item_ pi.progress = sprintf('[%5.1f%%] ', progress_) pi.run!(&block) end |
Instance Method Details
#change_name(new_name) ⇒ Object
18 19 20 21 |
# File 'lib/array_with_progress/array_progress_item.rb', line 18 def change_name(new_name) set_name(new_name) reprint! end |
#expand_name(extra_name) ⇒ Object
23 24 25 26 |
# File 'lib/array_with_progress/array_progress_item.rb', line 23 def (extra_name) self.extra_name = extra_name reprint! end |
#run! ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/array_with_progress/array_progress_item.rb', line 28 def run! self.status = nil self.extra_name = '' set_name(item) reprint! self.status = process_status_code(yield(item, self)) reprint! print "\n" end |