Class: WunderMarkdown::Task
- Inherits:
-
Struct
- Object
- Struct
- WunderMarkdown::Task
- Defined in:
- lib/wunder_markdown/task.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#client ⇒ Object
Returns the value of attribute client.
-
#id ⇒ Object
Returns the value of attribute id.
-
#note ⇒ Object
Returns the value of attribute note.
-
#parent_id ⇒ Object
Returns the value of attribute parent_id.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
3 4 5 |
# File 'lib/wunder_markdown/task.rb', line 3 def children @children end |
#client ⇒ Object
Returns the value of attribute client.
3 4 5 |
# File 'lib/wunder_markdown/task.rb', line 3 def client @client end |
#id ⇒ Object
Returns the value of attribute id
2 3 4 |
# File 'lib/wunder_markdown/task.rb', line 2 def id @id end |
#note ⇒ Object
Returns the value of attribute note
2 3 4 |
# File 'lib/wunder_markdown/task.rb', line 2 def note @note end |
#parent_id ⇒ Object
Returns the value of attribute parent_id
2 3 4 |
# File 'lib/wunder_markdown/task.rb', line 2 def parent_id @parent_id end |
#title ⇒ Object
Returns the value of attribute title
2 3 4 |
# File 'lib/wunder_markdown/task.rb', line 2 def title @title end |
Instance Method Details
#root? ⇒ Boolean
5 6 7 |
# File 'lib/wunder_markdown/task.rb', line 5 def root? parent_id.nil? end |
#to_markdown ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/wunder_markdown/task.rb', line 9 def to_markdown if root? markdown = "## #{title} \n" if note && note != '' markdown += " \n" note.chars.each_slice(80) do |slice| markdown += "> #{slice.join}\n" end end if children.any? markdown += " \n" markdown += children.map(&:to_markdown).join(" \n") end markdown else "* #{title} \n" end end |