Class: Krikri::XmlParser::Value
- Inherits:
-
Parser::Value
- Object
- Parser::Value
- Krikri::XmlParser::Value
- Defined in:
- lib/krikri/parsers/xml_parser.rb
Overview
An XML Parser Value node class
Instance Attribute Summary collapse
-
#namespaces ⇒ Object
Returns the value of attribute namespaces.
-
#node ⇒ Object
Returns the value of attribute node.
Instance Method Summary collapse
- #attributes ⇒ Object
- #children ⇒ Object
-
#initialize(node, namespaces) ⇒ Value
constructor
A new instance of Value.
- #value ⇒ Object
- #values? ⇒ Boolean
Methods inherited from Parser::Value
#[], #attribute?, #child?, #method_missing, #respond_to_missing
Constructor Details
#initialize(node, namespaces) ⇒ Value
Returns a new instance of Value.
39 40 41 42 43 |
# File 'lib/krikri/parsers/xml_parser.rb', line 39 def initialize(node, namespaces) node = node.root if node.xml? @node = node @namespaces = namespaces end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Krikri::Parser::Value
Instance Attribute Details
#namespaces ⇒ Object
Returns the value of attribute namespaces.
36 37 38 |
# File 'lib/krikri/parsers/xml_parser.rb', line 36 def namespaces @namespaces end |
#node ⇒ Object
Returns the value of attribute node.
36 37 38 |
# File 'lib/krikri/parsers/xml_parser.rb', line 36 def node @node end |
Instance Method Details
#attributes ⇒ Object
45 46 47 |
# File 'lib/krikri/parsers/xml_parser.rb', line 45 def attributes @node.attributes.keys.map(&:to_sym) end |
#children ⇒ Object
49 50 51 52 53 54 |
# File 'lib/krikri/parsers/xml_parser.rb', line 49 def children @node.element_children.map do |child| return child.name unless child.namespace "#{@namespaces.key(child.namespace.href)}:#{child.name}" end end |
#value ⇒ Object
56 57 58 |
# File 'lib/krikri/parsers/xml_parser.rb', line 56 def value @node.content end |
#values? ⇒ Boolean
60 61 62 |
# File 'lib/krikri/parsers/xml_parser.rb', line 60 def values? !select_values.empty? end |