Class: Muon::Entry
- Inherits:
-
Object
- Object
- Muon::Entry
- Defined in:
- lib/muon/entry.rb
Instance Attribute Summary collapse
-
#end_time ⇒ Object
readonly
Returns the value of attribute end_time.
-
#parent_hash ⇒ Object
readonly
Returns the value of attribute parent_hash.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
Class Method Summary collapse
Instance Method Summary collapse
- #duration ⇒ Object
-
#initialize(start_time, end_time, parent_hash = nil) ⇒ Entry
constructor
A new instance of Entry.
- #to_s ⇒ Object
- #with_parent_hash(new_parent_hash) ⇒ Object
Constructor Details
#initialize(start_time, end_time, parent_hash = nil) ⇒ Entry
Returns a new instance of Entry.
7 8 9 10 |
# File 'lib/muon/entry.rb', line 7 def initialize(start_time, end_time, parent_hash = nil) @start_time, @end_time = start_time, end_time @parent_hash = parent_hash end |
Instance Attribute Details
#end_time ⇒ Object (readonly)
Returns the value of attribute end_time.
5 6 7 |
# File 'lib/muon/entry.rb', line 5 def end_time @end_time end |
#parent_hash ⇒ Object (readonly)
Returns the value of attribute parent_hash.
5 6 7 |
# File 'lib/muon/entry.rb', line 5 def parent_hash @parent_hash end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
5 6 7 |
# File 'lib/muon/entry.rb', line 5 def start_time @start_time end |
Class Method Details
.from_s(str) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/muon/entry.rb', line 26 def self.from_s(str) parent_hash = str.lines.to_a[0].sub(/^parent /, "").strip parent_hash = nil if parent_hash == "" start_time, end_time = *str.lines.to_a[1].strip.split(",") new(Time.parse(start_time), Time.parse(end_time), parent_hash) end |
Instance Method Details
#duration ⇒ Object
12 13 14 |
# File 'lib/muon/entry.rb', line 12 def duration (end_time - start_time).to_i end |
#to_s ⇒ Object
21 22 23 24 |
# File 'lib/muon/entry.rb', line 21 def to_s "parent #{parent_hash}\n" + "#{start_time},#{end_time}\n" end |