Class: Gpuzzletime::Entry
- Inherits:
-
Object
- Object
- Gpuzzletime::Entry
- Defined in:
- lib/gpuzzletime/entry.rb
Overview
Dataclass to wrap an entry
Instance Attribute Summary collapse
-
#account ⇒ Object
readonly
allow to read everything.
-
#billable ⇒ Object
readonly
allow to read everything.
-
#date ⇒ Object
allow to read everything.
-
#description ⇒ Object
allow to read everything.
-
#finish_time ⇒ Object
allow to read everything.
-
#start_time ⇒ Object
allow to read everything.
-
#tags ⇒ Object
allow to read everything.
-
#ticket ⇒ Object
allow to read everything.
Class Method Summary collapse
Instance Method Summary collapse
- #from_timelog(matched_line) ⇒ Object
- #hidden? ⇒ Boolean
- #infer_ptime_settings ⇒ Object
-
#initialize(config = Configuration.instance) ⇒ Entry
constructor
A new instance of Entry.
- #to_s ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(config = Configuration.instance) ⇒ Entry
Returns a new instance of Entry.
13 14 15 16 |
# File 'lib/gpuzzletime/entry.rb', line 13 def initialize(config = Configuration.instance) @config = config @script = Script.new(@config[:dir]) end |
Instance Attribute Details
#account ⇒ Object (readonly)
allow to read everything
7 8 9 |
# File 'lib/gpuzzletime/entry.rb', line 7 def account @account end |
#billable ⇒ Object (readonly)
allow to read everything
7 8 9 |
# File 'lib/gpuzzletime/entry.rb', line 7 def billable @billable end |
#date ⇒ Object
allow to read everything
7 8 9 |
# File 'lib/gpuzzletime/entry.rb', line 7 def date @date end |
#description ⇒ Object
allow to read everything
7 8 9 |
# File 'lib/gpuzzletime/entry.rb', line 7 def description @description end |
#finish_time ⇒ Object
allow to read everything
7 8 9 |
# File 'lib/gpuzzletime/entry.rb', line 7 def finish_time @finish_time end |
#start_time ⇒ Object
allow to read everything
7 8 9 |
# File 'lib/gpuzzletime/entry.rb', line 7 def start_time @start_time end |
#tags ⇒ Object
allow to read everything
7 8 9 |
# File 'lib/gpuzzletime/entry.rb', line 7 def @tags end |
#ticket ⇒ Object
allow to read everything
7 8 9 |
# File 'lib/gpuzzletime/entry.rb', line 7 def ticket @ticket end |
Class Method Details
.from_timelog(matched_line) ⇒ Object
19 20 21 22 23 |
# File 'lib/gpuzzletime/entry.rb', line 19 def from_timelog(matched_line) entry = new entry.from_timelog(matched_line) entry end |
Instance Method Details
#from_timelog(matched_line) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/gpuzzletime/entry.rb', line 26 def from_timelog(matched_line) self.date = matched_line[:date] self.ticket = matched_line[:ticket] self.description = matched_line[:description] self.finish_time = matched_line[:time] self. = matched_line[:tags] infer_ptime_settings end |
#hidden? ⇒ Boolean
50 51 52 |
# File 'lib/gpuzzletime/entry.rb', line 50 def hidden? @description.match(/\*\*$/) # hide lunch and breaks end |
#infer_ptime_settings ⇒ Object
54 55 56 57 |
# File 'lib/gpuzzletime/entry.rb', line 54 def infer_ptime_settings @account = infer_account @billable = infer_billable end |
#to_s ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/gpuzzletime/entry.rb', line 59 def to_s [ @start_time, '-', @finish_time, [ @ticket, @description, @tags, @account, ].compact.join(' : '), ].compact.join(' ') end |
#valid? ⇒ Boolean
46 47 48 |
# File 'lib/gpuzzletime/entry.rb', line 46 def valid? @start_time && !hidden? end |