Class: DataIsland
- Inherits:
-
Object
- Object
- DataIsland
- Defined in:
- lib/dataisland.rb
Instance Attribute Summary collapse
-
#html_doc ⇒ Object
readonly
Returns the value of attribute html_doc.
Instance Method Summary collapse
-
#initialize(location) ⇒ DataIsland
constructor
e.g.
Constructor Details
#initialize(location) ⇒ DataIsland
e.g. url = ‘jamesrobertson.eu/index-template.html’
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/dataisland.rb', line 16 def initialize(location) buffer, typex = RXFHelper.read(location) @html_doc = Rexle.new(buffer) #exit @html_doc.xpath('//script[@class="dataisland"]').map(&:delete) @html_doc.xpath('//div[@datactl]').map(&:delete) @html_doc.root.element('body').attributes.delete :onload h = @html_doc.element('//object').attributes path = { url: -> {File.dirname(location)}, file: -> {File.(File.dirname(location))}, xml: -> {File.('.')}} @location = path[typex].call @html_doc.xpath("//object[@type='text/xml']").each do |x| h = x.attributes tmp, type2 = RXFHelper.read(h[:data]) location2 = case h[:data] when /^https?:\/\// h[:data] when /^\// @location + h[:data] else @location +'/' + h[:data] end dynarex = Dynarex.new location2 records = (h[:order] and h[:order][/^desc|descending$/]) ? dynarex.flat_records.reverse : dynarex.flat_records xpath = "//*[@datasrc='" + '#' + h[:id] + "']" @html_doc.xpath(xpath).each do |island| render(records, x.attributes, island.element('//*[@datafld]')); end x.delete end end |
Instance Attribute Details
#html_doc ⇒ Object (readonly)
Returns the value of attribute html_doc.
12 13 14 |
# File 'lib/dataisland.rb', line 12 def html_doc @html_doc end |