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) ⇒ Boolean
Equals method to compare two DailyLog objects.
-
#initialize(params = {}) ⇒ DailyLog
constructor
A new instance of DailyLog.
-
#people ⇒ Hash<String, Integer>
Returns a hash of people mentioned in the log for the current day with the number of times they are mentioned.
-
#people? ⇒ Boolean
Returns true if there are people mentioned in any entry of the current day.
-
#tags ⇒ Array<String>
Returns a sorted list of tags used in the entries for the current day.
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) ⇒ Boolean
Equals method to compare two DailyLog objects.
50 51 52 |
# File 'lib/daily_log.rb', line 50 def ==(other) date == other.date && entries == other.entries end |
#people ⇒ Hash<String, Integer>
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 ~.
30 31 32 |
# File 'lib/daily_log.rb', line 30 def people entries.map(&:people).flatten.tally end |
#people? ⇒ Boolean
Returns true if there are people mentioned in any entry of the current day.
21 22 23 |
# File 'lib/daily_log.rb', line 21 def people? people.size.positive? end |
#tags ⇒ Array<String>
Returns a sorted list of tags used in the entries for the current day.
42 43 44 |
# File 'lib/daily_log.rb', line 42 def entries.flat_map(&:tags).uniq.sort end |