Class: AsciiTracker::Record
- Inherits:
-
Object
- Object
- AsciiTracker::Record
- Defined in:
- lib/asciitracker/record.rb
Direct Known Subclasses
Constant Summary collapse
- Defaults =
{ :date => Date.today, :span => 0.0, :desc => nil }
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#desc ⇒ Object
readonly
Returns the value of attribute desc.
-
#span ⇒ Object
readonly
Returns the value of attribute span.
Class Method Summary collapse
-
.hours_to_dhm(hours) ⇒ Object
35.25 -> [1, 11, 15].
Instance Method Summary collapse
-
#initialize(values = {}) ⇒ Record
constructor
span may be any valid HHMM format value keys: :date, :span, and :desc.
- #to_s ⇒ Object
Constructor Details
#initialize(values = {}) ⇒ Record
span may be any valid HHMM format value keys: :date, :span, and :desc
12 13 14 15 16 17 |
# File 'lib/asciitracker/record.rb', line 12 def initialize values = {} #date, span, desc = nil values = Defaults.merge(values) @date = values[:date] @span = HHMM.new(values[:span]).to_f @desc = values[:desc] end |
Instance Attribute Details
#date ⇒ Object (readonly)
Returns the value of attribute date.
4 5 6 |
# File 'lib/asciitracker/record.rb', line 4 def date @date end |
#desc ⇒ Object (readonly)
Returns the value of attribute desc.
4 5 6 |
# File 'lib/asciitracker/record.rb', line 4 def desc @desc end |
#span ⇒ Object (readonly)
Returns the value of attribute span.
4 5 6 |
# File 'lib/asciitracker/record.rb', line 4 def span @span end |
Class Method Details
.hours_to_dhm(hours) ⇒ Object
35.25 -> [1, 11, 15]
20 21 22 23 24 25 |
# File 'lib/asciitracker/record.rb', line 20 def self.hours_to_dhm(hours) d = hours.to_i / 8 h = (hours - 8*d).to_i m = ((60 * (hours - 8*d - h)) + 0.5).to_i [d, h, m] end |