Class: Ptimelog::Entry
- Inherits:
-
Object
- Object
- Ptimelog::Entry
- Defined in:
- lib/ptimelog/entry.rb
Overview
Dataclass to wrap an entry
Constant Summary collapse
- BILLABLE =
1- NON_BILLABLE =
0
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
- #billable? ⇒ Boolean
- #from_timelog(matched_line) ⇒ Object
- #hidden? ⇒ Boolean
-
#infer_ptime_settings ⇒ Object
this method will be reduced in 0.7, when support for parsers is removed.
-
#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.
16 17 18 19 |
# File 'lib/ptimelog/entry.rb', line 16 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/ptimelog/entry.rb', line 7 def account @account end |
#billable ⇒ Object (readonly)
allow to read everything
7 8 9 |
# File 'lib/ptimelog/entry.rb', line 7 def billable @billable end |
#date ⇒ Object
allow to read everything
7 8 9 |
# File 'lib/ptimelog/entry.rb', line 7 def date @date end |
#description ⇒ Object
allow to read everything
7 8 9 |
# File 'lib/ptimelog/entry.rb', line 7 def description @description end |
#finish_time ⇒ Object
allow to read everything
7 8 9 |
# File 'lib/ptimelog/entry.rb', line 7 def finish_time @finish_time end |
#start_time ⇒ Object
allow to read everything
7 8 9 |
# File 'lib/ptimelog/entry.rb', line 7 def start_time @start_time end |
#tags ⇒ Object
allow to read everything
7 8 9 |
# File 'lib/ptimelog/entry.rb', line 7 def end |
#ticket ⇒ Object
allow to read everything
7 8 9 |
# File 'lib/ptimelog/entry.rb', line 7 def ticket @ticket end |
Class Method Details
.from_timelog(matched_line) ⇒ Object
22 23 24 25 26 |
# File 'lib/ptimelog/entry.rb', line 22 def from_timelog(matched_line) entry = new entry.from_timelog(matched_line) entry end |
Instance Method Details
#billable? ⇒ Boolean
62 63 64 |
# File 'lib/ptimelog/entry.rb', line 62 def billable? @billable == BILLABLE end |
#from_timelog(matched_line) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/ptimelog/entry.rb', line 29 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
58 59 60 |
# File 'lib/ptimelog/entry.rb', line 58 def hidden? @description.to_s.end_with?('**') # hide lunch and breaks end |
#infer_ptime_settings ⇒ Object
this method will be reduced in 0.7, when support for parsers is removed
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/ptimelog/entry.rb', line 67 def infer_ptime_settings return if hidden? if @script.inferer(script_name).exist? @account, @billable = infer_account_and_billable else @account = infer_account @billable = infer_billable end end |
#to_s ⇒ Object
78 79 80 81 82 83 |
# File 'lib/ptimelog/entry.rb', line 78 def to_s [ @start_time, '-', @finish_time, [@ticket, @description, , @account].compact.join(' : '), ].compact.join(' ') end |
#valid? ⇒ Boolean
54 55 56 |
# File 'lib/ptimelog/entry.rb', line 54 def valid? @start_time && !hidden? end |