Class: ArrayProgressItem

Inherits:
Object
  • Object
show all
Defined in:
lib/array_with_progress/array_progress_item.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#extra_nameObject

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

#itemObject

Returns the value of attribute item.



6
7
8
# File 'lib/array_with_progress/array_progress_item.rb', line 6

def item
  @item
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/array_with_progress/array_progress_item.rb', line 8

def name
  @name
end

#parentObject

Returns the value of attribute parent.



5
6
7
# File 'lib/array_with_progress/array_progress_item.rb', line 5

def parent
  @parent
end

#progressObject

Returns the value of attribute progress.



8
9
10
# File 'lib/array_with_progress/array_progress_item.rb', line 8

def progress
  @progress
end

#statusObject

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 expand_name(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