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.
37 38 39 40 41 |
# File 'lib/krikri/parsers/xml_parser.rb', line 37 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.
34 35 36 |
# File 'lib/krikri/parsers/xml_parser.rb', line 34 def namespaces @namespaces end |
#node ⇒ Object
Returns the value of attribute node.
34 35 36 |
# File 'lib/krikri/parsers/xml_parser.rb', line 34 def node @node end |
Instance Method Details
#attributes ⇒ Object
43 44 45 |
# File 'lib/krikri/parsers/xml_parser.rb', line 43 def attributes @node.attributes.keys.map(&:to_sym) end |
#children ⇒ Object
47 48 49 50 51 52 |
# File 'lib/krikri/parsers/xml_parser.rb', line 47 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
54 55 56 |
# File 'lib/krikri/parsers/xml_parser.rb', line 54 def value @node.content end |
#values? ⇒ Boolean
58 59 60 |
# File 'lib/krikri/parsers/xml_parser.rb', line 58 def values? !select_values.empty? end |