Class: Nokorexi
- Inherits:
-
Object
- Object
- Nokorexi
- Defined in:
- lib/nokorexi.rb
Instance Attribute Summary collapse
-
#to_doc ⇒ Object
readonly
Returns the value of attribute to_doc.
-
#to_s ⇒ Object
readonly
Returns the value of attribute to_s.
Instance Method Summary collapse
-
#initialize(x, noscript: true, debug: false) {|raw_doc| ... } ⇒ Nokorexi
constructor
A new instance of Nokorexi.
Constructor Details
#initialize(x, noscript: true, debug: false) {|raw_doc| ... } ⇒ Nokorexi
Returns a new instance of Nokorexi.
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(" ",' ')) 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_doc ⇒ Object (readonly)
Returns the value of attribute to_doc.
12 13 14 |
# File 'lib/nokorexi.rb', line 12 def to_doc @to_doc end |
#to_s ⇒ Object (readonly)
Returns the value of attribute to_s.
12 13 14 |
# File 'lib/nokorexi.rb', line 12 def to_s @to_s end |