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]

Iimpediments 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() { |config| ... } 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
  entry = new(
    Date.today,
    config.current,
    config.previous,
    config.impediments,
    config.notes
  )
  yield config if block_given?
  entry
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 81
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 94
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 102
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 117
def to_json
  to_h.to_json
end