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(file) ⇒ Document




16
17
18
19
20
# File 'lib/taskpaper/document.rb', line 16

def initialize(file)
  @filename = file
  @text = File.open(filename, "r").read
  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

Instance Method Details

#inspectObject



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

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



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

def to_html
  # TODO: to_html
end

#to_jsonObject



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

def to_json
  # TODO: to_json
end

#to_textObject



22
23
24
# File 'lib/taskpaper/document.rb', line 22

def to_text
  @text
end