Class: Taskdown::Manager
- Inherits:
-
Object
- Object
- Taskdown::Manager
- Defined in:
- lib/taskdown/manager.rb
Instance Attribute Summary collapse
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(string) ⇒ Manager
constructor
A new instance of Manager.
- #projects ⇒ Object
- #to_hash ⇒ Object
- #to_json ⇒ Object
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
#text ⇒ Object (readonly)
Returns the value of attribute text.
2 3 4 |
# File 'lib/taskdown/manager.rb', line 2 def text @text end |
Instance Method Details
#projects ⇒ Object
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_hash ⇒ Object
14 15 16 |
# File 'lib/taskdown/manager.rb', line 14 def to_hash { projects: projects.map(&:to_hash) } end |
#to_json ⇒ Object
18 19 20 |
# File 'lib/taskdown/manager.rb', line 18 def to_json to_hash.to_json end |