Class: Pomodoro::Formats::Today::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/pomodoro/formats/today/task/metadata.rb

Overview

  • A task. #cool Log about how is it going with the task.

    One more paragraph.

    ✔ Subtask 1. ✘ Subtask 2.

    • Subtask 3.

    Postponed: I got bored of it.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lines: [], subtasks: [], metadata: {}) ⇒ Metadata

Returns a new instance of Metadata.



16
17
18
19
20
21
# File 'lib/pomodoro/formats/today/task/metadata.rb', line 16

def initialize(lines: [], subtasks: [], metadata: {})
  @lines, @subtasks, @metadata = lines, subtasks, 
  @lines.is_a?(Array)    || raise(ArgumentError.new("Lines must be an array!"))
  @subtasks.is_a?(Array) || raise(ArgumentError.new("Subtasks must be an array!"))
  @metadata.is_a?(Hash)  || raise(ArgumentError.new("Metadata must be an array!"))
end

Instance Attribute Details

#linesObject (readonly)

Returns the value of attribute lines.



15
16
17
# File 'lib/pomodoro/formats/today/task/metadata.rb', line 15

def lines
  @lines
end

#metadataObject (readonly)

Returns the value of attribute metadata.



15
16
17
# File 'lib/pomodoro/formats/today/task/metadata.rb', line 15

def 
  @metadata
end

#subtasksObject (readonly)

Returns the value of attribute subtasks.



15
16
17
# File 'lib/pomodoro/formats/today/task/metadata.rb', line 15

def subtasks
  @subtasks
end

Instance Method Details

#[]=(key, value) ⇒ Object



23
24
25
26
27
# File 'lib/pomodoro/formats/today/task/metadata.rb', line 23

def []=(key, value)
  if @metadata['Postponed'] && key == 'Failed'
    raise ArgumentError.new("....")
  end
end

#to_sObject



29
30
31
32
33
34
35
# File 'lib/pomodoro/formats/today/task/metadata.rb', line 29

def to_s
  @lines.join("\n\n")
  @subtasks.join("\n")
  @metadata.reduce(Array.new) do |buffer, (key, value)|
    buffer << "#{key}: #{value}"
  end
end