class StandupMD::Entry

Class for handling single entries. Includes the comparable module, and compares by date.

Attributes

current[RW]

The tasks for today.

@return [Array]

date[RW]

The date of the entry.

@param [Date] date

@return [Date]

impediments[RW]

Impediments for this entry.

@return [Array]

notes[RW]

Nnotes to add to this entry.

@return [Array]

previous[RW]

The tasks from the previous day.

@return [Array]

Public Class Methods

config() click to toggle source

Access to the class's configuration.

@return [StandupMD::Config::Entry]

# File lib/standup_md/entry.rb, line 16
def self.config
  @config ||= StandupMD.config.entry
end
create() { |entry| ... } click to toggle source

Creates a generic entry. Default values can be set via configuration. Yields the entry if a block is passed so you can change values.

@return [StandupMD::Entry]

# 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
new(date, current, previous, impediments, notes = []) click to toggle source

Constructs instance of StandupMD::Entry.

@param [Date] date

@param [Array] current

@param [Array] previous

@param [Array] impediments

@param [Array] notes

# 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

Public Instance Methods

<=>(other) click to toggle source

Sorting method for Comparable. Entries are compared by date.

# File lib/standup_md/entry.rb, line 92
def <=>(other)
  date <=> other.date
end
to_h() click to toggle source

Entry as a hash .

@return [Hash]

# File lib/standup_md/entry.rb, line 100
def to_h
  {
    date => {
      'current'     => current,
      'previous'    => previous,
      'impediments' => impediments,
      'notes'       => notes
    }
  }
end
to_json() click to toggle source

Entry as a json object.

@return [String]

# File lib/standup_md/entry.rb, line 115
def to_json
  to_h.to_json
end