Class: DailyLog
Overview
DailyLog is a container for a day’s work log.
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.
13 14 15 16 |
# File 'lib/daily_log.rb', line 13 def initialize(params = {}) @date = params[:date] @entries = params[:entries] end |
Instance Attribute Details
#date ⇒ Object
Represents a single day’s work log.
11 12 13 |
# File 'lib/daily_log.rb', line 11 def date @date end |
#entries ⇒ Object
Represents a single day’s work log.
11 12 13 |
# File 'lib/daily_log.rb', line 11 def entries @entries end |
Instance Method Details
#==(other) ⇒ Object
32 33 34 |
# File 'lib/daily_log.rb', line 32 def ==(other) date == other.date && entries == other.entries end |
#people ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/daily_log.rb', line 23 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
18 19 20 21 |
# File 'lib/daily_log.rb', line 18 def people? # Returns true if there are people mentioned in any entry of the current day. people.size.positive? end |