Class: DailyLog
Instance Attribute Summary collapse
-
#date ⇒ Object
Represents a single day’s work log.
-
#entries ⇒ Object
Represents a single day’s work log.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(params = {}) ⇒ DailyLog
constructor
A new instance of DailyLog.
- #people ⇒ Object
- #people? ⇒ Boolean
Methods included from Hashify
Constructor Details
#initialize(params = {}) ⇒ DailyLog
Returns a new instance of DailyLog.
12 13 14 15 |
# File 'worklog/daily_log.rb', line 12 def initialize(params = {}) @date = params[:date] @entries = params[:entries] end |
Instance Attribute Details
#date ⇒ Object
Represents a single day’s work log.
10 11 12 |
# File 'worklog/daily_log.rb', line 10 def date @date end |
#entries ⇒ Object
Represents a single day’s work log.
10 11 12 |
# File 'worklog/daily_log.rb', line 10 def entries @entries end |
Instance Method Details
#==(other) ⇒ Object
31 32 33 |
# File 'worklog/daily_log.rb', line 31 def ==(other) date == other.date && entries == other.entries end |
#people ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'worklog/daily_log.rb', line 22 def people # Returns a hash of people mentioned in the log for the current day # with the number of times they are mentioned. # People are defined as words starting with @ or ~. # # @return [Hash<String, Integer>] entries.map(&:people).flatten.tally end |
#people? ⇒ Boolean
17 18 19 20 |
# File 'worklog/daily_log.rb', line 17 def people? # Returns true if there are people mentioned in any entry of the current day. people.size.positive? end |