Class: Taskpaper::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/taskpaper/document.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#docObject

Returns the value of attribute doc.



4
5
6
# File 'lib/taskpaper/document.rb', line 4

def doc
  @doc
end

#filenameObject

Returns the value of attribute filename.



4
5
6
# File 'lib/taskpaper/document.rb', line 4

def filename
  @filename
end

#textObject

Returns the value of attribute text.



4
5
6
# File 'lib/taskpaper/document.rb', line 4

def text
  @text
end

Instance Method Details

#inspectObject



37
38
39
# File 'lib/taskpaper/document.rb', line 37

def inspect
  doc.map(&:inspect)
end

#parseObject



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_htmlObject



29
30
31
# File 'lib/taskpaper/document.rb', line 29

def to_html
  # TODO: to_html
end

#to_jsonObject



33
34
35
# File 'lib/taskpaper/document.rb', line 33

def to_json
  # TODO: to_json
end

#to_textObject



25
26
27
# File 'lib/taskpaper/document.rb', line 25

def to_text
  text
end