Class: TablizedOutput::Percentage
Instance Attribute Summary collapse
-
#v ⇒ Object
readonly
Returns the value of attribute v.
-
#w ⇒ Object
readonly
Returns the value of attribute w.
Instance Method Summary collapse
-
#initialize(v, w = nil) ⇒ Percentage
constructor
A new instance of Percentage.
- #inspect ⇒ Object
- #length ⇒ Object
- #to_s ⇒ Object
Methods inherited from B
Constructor Details
#initialize(v, w = nil) ⇒ Percentage
Returns a new instance of Percentage.
111 |
# File 'lib/pve/helper.rb', line 111 def initialize( v, w=nil) @v, @w = v, w || 10 end |
Instance Attribute Details
#v ⇒ Object (readonly)
Returns the value of attribute v.
110 111 112 |
# File 'lib/pve/helper.rb', line 110 def v @v end |
#w ⇒ Object (readonly)
Returns the value of attribute w.
110 111 112 |
# File 'lib/pve/helper.rb', line 110 def w @w end |
Instance Method Details
#inspect ⇒ Object
113 |
# File 'lib/pve/helper.rb', line 113 def inspect() "#<TO:Percentage #{@v}%>" end |
#length ⇒ Object
112 |
# File 'lib/pve/helper.rb', line 112 def length() @w end |
#to_s ⇒ Object
115 116 117 118 119 120 121 122 |
# File 'lib/pve/helper.rb', line 115 def to_s #y = w - (v*w).round y = (v*w).round x = (100*v).round r = "%*s" % [w, 0==x ? '·' : x] #"\e[0m#{r[0...y]}\e[1;4;#{0.75>v ? 32 : 31}m#{r[y..-1]}\e[0m" "\e[1;4;#{0.75>v ? 32 : 31}m#{r[0...y]}\e[0m#{r[y..-1]}" end |