Class: Markdo::Task
- Inherits:
-
Object
- Object
- Markdo::Task
- Defined in:
- lib/markdo/models/task.rb
Instance Attribute Summary collapse
-
#line ⇒ Object
readonly
Returns the value of attribute line.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #attributes ⇒ Object
- #body ⇒ Object
- #complete? ⇒ Boolean
-
#initialize(line) ⇒ Task
constructor
A new instance of Task.
- #tags ⇒ Object
Constructor Details
#initialize(line) ⇒ Task
Returns a new instance of Task.
7 8 9 |
# File 'lib/markdo/models/task.rb', line 7 def initialize(line) @line = line end |
Instance Attribute Details
#line ⇒ Object (readonly)
Returns the value of attribute line.
5 6 7 |
# File 'lib/markdo/models/task.rb', line 5 def line @line end |
Instance Method Details
#==(other) ⇒ Object
11 12 13 |
# File 'lib/markdo/models/task.rb', line 11 def ==(other) other.line == line end |
#attributes ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/markdo/models/task.rb', line 29 def attributes a = line. scan(/\s@\S+/). map { |s| match_data = s.match(/@([a-zA-Z0-9]+)(\((.+)\))?/) if match_data key = match_data[1].downcase value = match_data[3] [key, TaskAttribute.new(key, value)] end } Hash[a] end |
#body ⇒ Object
19 20 21 22 23 |
# File 'lib/markdo/models/task.rb', line 19 def body line. sub(/\s*[-*] \[.\]\s+/, ''). sub(/\s*$/, '') end |
#complete? ⇒ Boolean
15 16 17 |
# File 'lib/markdo/models/task.rb', line 15 def complete? !!line.match(/\s*[-*] \[x\]\s+/) end |
#tags ⇒ Object
25 26 27 |
# File 'lib/markdo/models/task.rb', line 25 def attributes.keys end |