Class: Taskdown::Manager

Inherits:
Object
  • Object
show all
Defined in:
lib/taskdown/manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string) ⇒ Manager

Returns a new instance of Manager.



4
5
6
# File 'lib/taskdown/manager.rb', line 4

def initialize(string)
  @text = string
end

Instance Attribute Details

#textObject (readonly)

Returns the value of attribute text.



2
3
4
# File 'lib/taskdown/manager.rb', line 2

def text
  @text
end

Instance Method Details

#projectsObject



8
9
10
11
12
# File 'lib/taskdown/manager.rb', line 8

def projects
  text.split(/(?=^!)/).map do |project_string|
    Taskdown::Project.new(project_string)
  end
end

#to_hashObject



14
15
16
# File 'lib/taskdown/manager.rb', line 14

def to_hash
  { projects: projects.map(&:to_hash) }
end

#to_jsonObject



18
19
20
# File 'lib/taskdown/manager.rb', line 18

def to_json
  to_hash.to_json
end