Class: Pomodoro::Formats::Today::Metadata
- Inherits:
-
Object
- Object
- Pomodoro::Formats::Today::Metadata
- 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
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#subtasks ⇒ Object
readonly
Returns the value of attribute subtasks.
Instance Method Summary collapse
- #[]=(key, value) ⇒ Object
-
#initialize(lines: [], subtasks: [], metadata: {}) ⇒ Metadata
constructor
A new instance of Metadata.
- #to_s ⇒ Object
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
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
15 16 17 |
# File 'lib/pomodoro/formats/today/task/metadata.rb', line 15 def lines @lines end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
15 16 17 |
# File 'lib/pomodoro/formats/today/task/metadata.rb', line 15 def @metadata end |
#subtasks ⇒ Object (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_s ⇒ Object
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 |