Class: AwesomeXML::NodeEvaluator
- Inherits:
-
Object
- Object
- AwesomeXML::NodeEvaluator
- Defined in:
- lib/awesome_xml/node_evaluator.rb
Instance Method Summary collapse
-
#call ⇒ Object
Parses one or several nodes, depending on the ‘options` setting, according to the type passed in in the form of a class that handles the conversion.
-
#initialize(xml, xpath, type_class, options) ⇒ NodeEvaluator
constructor
Initialize an instance of this class with a Nokogiri::XML object, a string representing an XPath to the value(s) you want to parse, a type class (see ‘AwesomeXML::Type` for more info), and an options hash.
Constructor Details
#initialize(xml, xpath, type_class, options) ⇒ NodeEvaluator
Initialize an instance of this class with a Nokogiri::XML object, a string representing an XPath to the value(s) you want to parse, a type class (see ‘AwesomeXML::Type` for more info), and an options hash.
13 14 15 16 17 18 |
# File 'lib/awesome_xml/node_evaluator.rb', line 13 def initialize(xml, xpath, type_class, ) @xml = xml @xpath = xpath @type_class = type_class = end |
Instance Method Details
#call ⇒ Object
Parses one or several nodes, depending on the ‘options` setting, according to the type passed in in the form of a class that handles the conversion.
22 23 24 25 26 27 28 |
# File 'lib/awesome_xml/node_evaluator.rb', line 22 def call if [:array] all_nodes.map { |node| type_class.new(node, ).evaluate } else type_class.new(first_node, ).evaluate end end |