class Markdo::Task

Attributes

line[R]

Public Class Methods

new(line) click to toggle source
# File lib/markdo/models/task.rb, line 7
def initialize(line)
  @line = line
end

Public Instance Methods

==(other) click to toggle source
# File lib/markdo/models/task.rb, line 11
def ==(other)
  other.line == line
end
attributes() click to toggle source
# 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() click to toggle source
# File lib/markdo/models/task.rb, line 19
def body
  line.
    sub(/\s*[-*] \[.\]\s+/, '').
    sub(/\s*$/, '')
end
complete?() click to toggle source
# File lib/markdo/models/task.rb, line 15
def complete?
  !!line.match(/\s*[-*] \[x\]\s+/)
end
tags() click to toggle source
# File lib/markdo/models/task.rb, line 25
def tags
  attributes.keys
end