Class: Termite::Progress

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(desc, width = 35, color = false, *deco) ⇒ Progress

Returns a new instance of Progress.



87
88
89
90
91
92
# File 'lib/termite.rb', line 87

def initialize( desc, width = 35, color = false, *deco )
  @desc = desc
  @width = width
  @decorations = deco
  @decorations << :"fg_#{color}" if color
end

Instance Attribute Details

#decorationsObject

Returns the value of attribute decorations.



85
86
87
# File 'lib/termite.rb', line 85

def decorations
  @decorations
end

#descObject

Returns the value of attribute desc.



85
86
87
# File 'lib/termite.rb', line 85

def desc
  @desc
end

#stateObject

Returns the value of attribute state.



85
86
87
# File 'lib/termite.rb', line 85

def state
  @state
end

#widthObject

Returns the value of attribute width.



85
86
87
# File 'lib/termite.rb', line 85

def width
  @width
end

Instance Method Details

#barObject



103
104
105
106
107
108
109
110
111
# File 'lib/termite.rb', line 103

def bar
  completed = (@state * @width).to_i
  remaining = @width - completed
  make_bar_string
  Termite.decorate(@bs[0..(completed)],
                   :reverse, *@decorations) +
  Termite.decorate(@bs[(completed+1)..@width],
                   *@decorations)
end

#report(s = false) ⇒ Object



98
99
100
101
# File 'lib/termite.rb', line 98

def report( s = false )
  @state = s if s
  bar
end

#resetObject



94
95
96
# File 'lib/termite.rb', line 94

def reset
  @state = 0.0
end