Class: StandupMD::Task
- Inherits:
-
Object
- Object
- StandupMD::Task
- Defined in:
- lib/standup_md/task.rb
Overview
A single standup task. The text stays format-neutral, while indentation level lets parsers render nested tasks for their own formats.
Instance Attribute Summary collapse
-
#indent_level ⇒ Integer
readonly
The nesting level of the task.
-
#text ⇒ String
readonly
The task text.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Compares task contents.
-
#initialize(text, indent_level: 0) ⇒ Task
constructor
Constructs an instance of
StandupMD::Task. -
#to_markdown ⇒ String
The task rendered as a markdown list item.
-
#to_s ⇒ String
The format-neutral task text.
Constructor Details
#initialize(text, indent_level: 0) ⇒ Task
Constructs an instance of StandupMD::Task.
25 26 27 28 29 30 31 32 |
# File 'lib/standup_md/task.rb', line 25 def initialize(text, indent_level: 0) unless indent_level.is_a?(Integer) && !indent_level.negative? raise ArgumentError, "Indent level must be a non-negative integer" end @text = text.to_s @indent_level = indent_level end |
Instance Attribute Details
#indent_level ⇒ Integer (readonly)
The nesting level of the task.
18 19 20 |
# File 'lib/standup_md/task.rb', line 18 def indent_level @indent_level end |
#text ⇒ String (readonly)
The task text.
12 13 14 |
# File 'lib/standup_md/task.rb', line 12 def text @text end |
Instance Method Details
#==(other) ⇒ Object
Compares task contents.
53 54 55 56 57 58 |
# File 'lib/standup_md/task.rb', line 53 def ==(other) return text == other if other.is_a?(String) return false unless other.is_a?(Task) text == other.text && indent_level == other.indent_level end |
#to_markdown ⇒ String
The task rendered as a markdown list item.
46 47 48 49 |
# File 'lib/standup_md/task.rb', line 46 def to_markdown indent = " " * StandupMD.config.file.indent_width * indent_level "#{indent}#{StandupMD.config.file.bullet_character} #{text}" end |
#to_s ⇒ String
The format-neutral task text.
38 39 40 |
# File 'lib/standup_md/task.rb', line 38 def to_s text end |