Class: Taskdown::Task
- Inherits:
-
Object
- Object
- Taskdown::Task
- Defined in:
- lib/taskdown/task.rb
Instance Attribute Summary collapse
-
#modified_text ⇒ Object
readonly
Returns the value of attribute modified_text.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(string) ⇒ Task
constructor
A new instance of Task.
- #labels ⇒ Object
- #name ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(string) ⇒ Task
Returns a new instance of Task.
7 8 9 10 |
# File 'lib/taskdown/task.rb', line 7 def initialize(string) @text = string @modified_text = @text.dup end |
Instance Attribute Details
#modified_text ⇒ Object (readonly)
Returns the value of attribute modified_text.
5 6 7 |
# File 'lib/taskdown/task.rb', line 5 def modified_text @modified_text end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
5 6 7 |
# File 'lib/taskdown/task.rb', line 5 def text @text end |
Instance Method Details
#description ⇒ Object
16 17 18 |
# File 'lib/taskdown/task.rb', line 16 def description @description ||= modified_text.slice(/^\s+.+/m).chomp end |
#labels ⇒ Object
20 21 22 23 24 |
# File 'lib/taskdown/task.rb', line 20 def labels @labels ||= prestripped_labels.map do |label| label.gsub(/^\#/, '') end end |
#name ⇒ Object
12 13 14 |
# File 'lib/taskdown/task.rb', line 12 def name @name ||= modified_text.slice!(/^.+\n/) end |
#to_hash ⇒ Object
26 27 28 29 30 |
# File 'lib/taskdown/task.rb', line 26 def to_hash { name: name, description: description, labels: labels } end |