Class: Redpomo::Entry
- Inherits:
-
Object
- Object
- Redpomo::Entry
- Defined in:
- lib/redpomo/entry.rb
Instance Attribute Summary collapse
-
#datetime ⇒ Object
readonly
Returns the value of attribute datetime.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Class Method Summary collapse
Instance Method Summary collapse
- #date ⇒ Object
- #end_time ⇒ Object
-
#initialize(text, datetime, duration) ⇒ Entry
constructor
A new instance of Entry.
- #push! ⇒ Object
- #pushable? ⇒ Boolean
- #same_date?(entry) ⇒ Boolean
- #same_text?(entry) ⇒ Boolean
- #time ⇒ Object
- #to_task ⇒ Object
- #tracker ⇒ Object
Constructor Details
#initialize(text, datetime, duration) ⇒ Entry
Returns a new instance of Entry.
22 23 24 25 26 |
# File 'lib/redpomo/entry.rb', line 22 def initialize(text, datetime, duration) @text = text @datetime = datetime @duration = duration end |
Instance Attribute Details
#datetime ⇒ Object (readonly)
Returns the value of attribute datetime.
20 21 22 |
# File 'lib/redpomo/entry.rb', line 20 def datetime @datetime end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
20 21 22 |
# File 'lib/redpomo/entry.rb', line 20 def duration @duration end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
20 21 22 |
# File 'lib/redpomo/entry.rb', line 20 def text @text end |
Class Method Details
.csv_rows(text) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/redpomo/entry.rb', line 12 def self.csv_rows(text) if text.match /^Export data created/ CSV.parse text.split("\n")[4..-1].join("\n") else CSV.parse text end end |
Instance Method Details
#date ⇒ Object
28 29 30 |
# File 'lib/redpomo/entry.rb', line 28 def date datetime.to_date end |
#end_time ⇒ Object
36 37 38 |
# File 'lib/redpomo/entry.rb', line 36 def end_time time + duration end |
#push! ⇒ Object
52 53 54 |
# File 'lib/redpomo/entry.rb', line 52 def push! tracker.push_entry!(self) if pushable? end |
#pushable? ⇒ Boolean
56 57 58 |
# File 'lib/redpomo/entry.rb', line 56 def pushable? tracker.present? && tracker.pushable_entry?(self) end |
#same_date?(entry) ⇒ Boolean
40 41 42 |
# File 'lib/redpomo/entry.rb', line 40 def same_date?(entry) date == entry.date end |
#same_text?(entry) ⇒ Boolean
44 45 46 |
# File 'lib/redpomo/entry.rb', line 44 def same_text?(entry) text == entry.text end |
#time ⇒ Object
32 33 34 |
# File 'lib/redpomo/entry.rb', line 32 def time datetime.to_time end |
#to_task ⇒ Object
48 49 50 |
# File 'lib/redpomo/entry.rb', line 48 def to_task Task.new(nil, text) end |
#tracker ⇒ Object
60 61 62 |
# File 'lib/redpomo/entry.rb', line 60 def tracker to_task.tracker end |