Class: StandupMD::Entry
- Inherits:
-
Object
- Object
- StandupMD::Entry
- Includes:
- Comparable
- Defined in:
- lib/standup_md/entry.rb
Overview
Class for handling single entries. Includes the comparable module, and compares by date.
Instance Attribute Summary collapse
-
#current ⇒ Array
The tasks for today.
-
#date ⇒ Date
The date of the entry.
-
#impediments ⇒ Array
Impediments for this entry.
-
#notes ⇒ Array
Nnotes to add to this entry.
-
#previous ⇒ Array
The tasks from the previous day.
Class Method Summary collapse
-
.config ⇒ StandupMD::Config::Entry
Access to the class’s configuration.
-
.create ⇒ StandupMD::Entry
Creates a generic entry.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Sorting method for Comparable.
-
#initialize(date, current, previous, impediments, notes = []) ⇒ Entry
constructor
Constructs instance of
StandupMD::Entry. -
#to_h ⇒ Hash
Entry as a hash .
-
#to_json ⇒ String
Entry as a json object.
Constructor Details
#initialize(date, current, previous, impediments, notes = []) ⇒ Entry
Constructs instance of StandupMD::Entry.
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/standup_md/entry.rb', line 79 def initialize(date, current, previous, impediments, notes = []) raise unless date.is_a?(Date) @config = self.class.config @date = date @current = current @previous = previous @impediments = impediments @notes = notes end |
Instance Attribute Details
#current ⇒ Array
The tasks for today.
32 33 34 |
# File 'lib/standup_md/entry.rb', line 32 def current @current end |
#date ⇒ Date
The date of the entry.
26 27 28 |
# File 'lib/standup_md/entry.rb', line 26 def date @date end |
#impediments ⇒ Array
Impediments for this entry.
44 45 46 |
# File 'lib/standup_md/entry.rb', line 44 def impediments @impediments end |
#notes ⇒ Array
Nnotes to add to this entry.
50 51 52 |
# File 'lib/standup_md/entry.rb', line 50 def notes @notes end |
#previous ⇒ Array
The tasks from the previous day.
38 39 40 |
# File 'lib/standup_md/entry.rb', line 38 def previous @previous end |
Class Method Details
.config ⇒ StandupMD::Config::Entry
Access to the class’s configuration.
16 17 18 |
# File 'lib/standup_md/entry.rb', line 16 def self.config @config ||= StandupMD.config.entry end |
.create ⇒ StandupMD::Entry
Creates a generic entry. Default values can be set via configuration. Yields the entry if a block is passed so you can change values.
57 58 59 60 61 62 63 64 65 |
# File 'lib/standup_md/entry.rb', line 57 def self.create new( Date.today, config.current, config.previous, config.impediments, config.notes ).tap { |entry| yield entry if block_given? } end |
Instance Method Details
#<=>(other) ⇒ Object
Sorting method for Comparable. Entries are compared by date.
92 93 94 |
# File 'lib/standup_md/entry.rb', line 92 def <=>(other) date <=> other.date end |
#to_h ⇒ Hash
Entry as a hash .
100 101 102 103 104 105 106 107 108 109 |
# File 'lib/standup_md/entry.rb', line 100 def to_h { date => { "current" => current, "previous" => previous, "impediments" => impediments, "notes" => notes } } end |
#to_json ⇒ String
Entry as a json object.
115 116 117 |
# File 'lib/standup_md/entry.rb', line 115 def to_json to_h.to_json end |