Class: ChupaText::TimeoutValue
- Inherits:
-
Object
- Object
- ChupaText::TimeoutValue
- Includes:
- Loggable, Comparable
- Defined in:
- lib/chupa-text/timeout-value.rb
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
-
#initialize(tag, value) ⇒ TimeoutValue
constructor
A new instance of TimeoutValue.
- #to_s ⇒ Object
Constructor Details
#initialize(tag, value) ⇒ TimeoutValue
Returns a new instance of TimeoutValue.
25 26 27 28 |
# File 'lib/chupa-text/timeout-value.rb', line 25 def initialize(tag, value) value = parse(value) if value.is_a?(String) @raw = value end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
24 25 26 |
# File 'lib/chupa-text/timeout-value.rb', line 24 def raw @raw end |
Instance Method Details
#to_s ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/chupa-text/timeout-value.rb', line 30 def to_s return "" if @raw.nil? if @raw < 1 "%.2fms" % (@raw * 1000.0) elsif @raw < 60 "%.2fs" % @raw elsif @raw < (60 * 60) "%.2fm" % (@raw / 60.0) else "%.2fh" % (@raw / 60.0 / 60.0) end end |