Sha256: d90cc22b8da8df13422620a3c2f37b137b2197497f69d4a58309fe20c4488b2c

Contents?: true

Size: 780 Bytes

Versions: 2

Compression:

Stored size: 780 Bytes

Contents

#coding: utf-8

module Wombat
  module PropertyLocator
    def locate metadata
      [metadata.event_props, metadata.venue_props, metadata.location_props].flat_map { |p| p.all_properties }.each do |p|
        p.result = locate_property(p).first
      end
    end

    private 
    def locate_property property
      result = locate_selector(property.selector, property.namespaces)
      result.map! {|r| r.inner_html } if property.format == :html
      result.map {|r| r.strip }
    end

    def locate_selector selector, namespaces = nil
      return [selector.to_s] if selector.is_a? Symbol
      return context.xpath selector[6..-1], namespaces if selector.start_with? "xpath="
      return context.css selector[4..-1] if selector.start_with? "css="
      nil
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wombat-0.1.2 lib/wombat/property_locator.rb
wombat-0.1.1 lib/wombat/property_locator.rb