Class: Wombat::Property::Locators::Base

Inherits:
Object
  • Object
show all
Includes:
Wombat::Processing::NodeSelector
Defined in:
lib/wombat/property/locators/base.rb

Overview

Abstract base class

Direct Known Subclasses

Follow, Headers, Html, Iterator, List, PropertyGroup, Text

Instance Method Summary collapse

Methods included from Wombat::Processing::NodeSelector

#select_nodes

Constructor Details

#initialize(property) ⇒ Base

Returns a new instance of Base.



11
12
13
# File 'lib/wombat/property/locators/base.rb', line 11

def initialize(property)
  @property = property
end

Instance Method Details

#locate(context, page = nil) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/wombat/property/locators/base.rb', line 15

def locate(context, page = nil)
  @context = context

  raw_data = yield if block_given?
  data = @property.respond_to?(:callback) && @property.callback ? @property.callback.call(raw_data) : raw_data

  @property.wombat_property_name ? { @property.wombat_property_name => data } : data
end