Class: Web2Text::LinePrinter

Inherits:
Object
  • Object
show all
Defined in:
lib/web2text/formatters.rb

Instance Method Summary collapse

Constructor Details

#initialize(crawl, output) ⇒ LinePrinter

Returns a new instance of LinePrinter.



4
5
6
7
# File 'lib/web2text/formatters.rb', line 4

def initialize(crawl, output)
  @output = output
  @first = true
end

Instance Method Details

#append(doc, uri) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/web2text/formatters.rb', line 9

def append(doc, uri)
  if !@first then
    @output.write "\n"
  end
  @first = false

  @output.write doc.gsub(/\n+/, ' ')
  self
end

#closeObject



19
20
21
# File 'lib/web2text/formatters.rb', line 19

def close
  @output.close
end