class Todo::Data::Parser

Constants

ID
STATUS
TAG

Public Instance Methods

parse() click to toggle source
# File lib/todo/data/parser.rb, line 13
def parse
  {
    id: id,
    text: text,
    status: status,
    tags: tags,
  }
end

Private Instance Methods

id() click to toggle source
# File lib/todo/data/parser.rb, line 28
def id
  line =~ ID && $1.to_i
end
status() click to toggle source
# File lib/todo/data/parser.rb, line 24
def status
  STATUSES.invert[line.match(STATUS) && $1]
end
tags() click to toggle source
# File lib/todo/data/parser.rb, line 36
def tags
  Hash[line.scan(TAG).map { |key, value| [key.to_sym, value] }]
end
text() click to toggle source
# File lib/todo/data/parser.rb, line 32
def text
  line.sub(STATUS, '').gsub(ID, '').gsub(TAG, '').rstrip
end