Class: Nokorexi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x, noscript: true, debug: false) {|raw_doc| ... } ⇒ Nokorexi

Returns a new instance of Nokorexi.

Yields:

  • (raw_doc)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/nokorexi.rb', line 14

def initialize(x, noscript: true, debug: false)

  raws = RXFHelper.read(x).first
  s = raws[/.*<\/html>$/m] || raws
  puts 's: ' + s.inspect if debug

  raw_doc = Nokogiri::HTML(s.gsub("&nbsp;",' '))
  raw_doc.xpath('//script').each(&:remove) if noscript
  yield(raw_doc) if block_given?

  @to_s = xml = raw_doc.xpath('html').to_xml
  @to_doc = Rexle.new(xml, debug: debug)

end

Instance Attribute Details

#to_docObject (readonly)

Returns the value of attribute to_doc.



12
13
14
# File 'lib/nokorexi.rb', line 12

def to_doc
  @to_doc
end

#to_sObject (readonly)

Returns the value of attribute to_s.



12
13
14
# File 'lib/nokorexi.rb', line 12

def to_s
  @to_s
end