Class: Taskpaper::Document
- Inherits:
-
Object
- Object
- Taskpaper::Document
- Defined in:
- lib/taskpaper/document.rb
Instance Attribute Summary collapse
-
#doc ⇒ Object
Returns the value of attribute doc.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(taskpaper) ⇒ Document
constructor
———————.
- #inspect ⇒ Object
- #parse ⇒ Object
- #to_html ⇒ Object
- #to_json ⇒ Object
- #to_text ⇒ Object
Constructor Details
#initialize(taskpaper) ⇒ Document
16 17 18 19 20 21 22 23 |
# File 'lib/taskpaper/document.rb', line 16 def initialize(taskpaper) if File.exists?(taskpaper) @text = File.open(taskpaper, "r").read else @text = taskpaper end parse end |
Instance Attribute Details
#doc ⇒ Object
Returns the value of attribute doc.
4 5 6 |
# File 'lib/taskpaper/document.rb', line 4 def doc @doc end |
#filename ⇒ Object
Returns the value of attribute filename.
4 5 6 |
# File 'lib/taskpaper/document.rb', line 4 def filename @filename end |
#text ⇒ Object
Returns the value of attribute text.
4 5 6 |
# File 'lib/taskpaper/document.rb', line 4 def text @text end |
Instance Method Details
#inspect ⇒ Object
37 38 39 |
# File 'lib/taskpaper/document.rb', line 37 def inspect doc.map(&:inspect) end |
#parse ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/taskpaper/document.rb', line 6 def parse @doc = [] text.each_line do |line| item = Taskpaper::Item.new line @doc << item.classify.new(line) end @doc end |
#to_html ⇒ Object
29 30 31 |
# File 'lib/taskpaper/document.rb', line 29 def to_html # TODO: to_html end |
#to_json ⇒ Object
33 34 35 |
# File 'lib/taskpaper/document.rb', line 33 def to_json # TODO: to_json end |
#to_text ⇒ Object
25 26 27 |
# File 'lib/taskpaper/document.rb', line 25 def to_text text end |