Class: Krikri::Parser
- Inherits:
-
Object
- Object
- Krikri::Parser
- Defined in:
- lib/krikri/parser.rb
Overview
Provides a generic interface for accessing properties from OriginalRecords. Implement the interface, and that of ‘Value` on an record-type basis.
parser = Krikri::Parser::MyParser.new(record)
parser.root # => #<Krikri::MyParser::Value:0x007f861888fea0>
Direct Known Subclasses
Defined Under Namespace
Classes: Value, ValueArray
Instance Attribute Summary collapse
-
#record ⇒ Object
readonly
Returns the value of attribute record.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Class Method Summary collapse
-
.parse(record, *args) ⇒ Krikri::Parser
Instantiates a parser object to wrap the record.
Instance Method Summary collapse
-
#initialize(record) ⇒ Parser
constructor
A new instance of Parser.
-
#local_name ⇒ String
The local_name of the OriginalRecord wrapped by this parser.
Constructor Details
#initialize(record) ⇒ Parser
Returns a new instance of Parser.
15 16 17 |
# File 'lib/krikri/parser.rb', line 15 def initialize(record) @record = record end |
Instance Attribute Details
#record ⇒ Object (readonly)
Returns the value of attribute record.
10 11 12 |
# File 'lib/krikri/parser.rb', line 10 def record @record end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
10 11 12 |
# File 'lib/krikri/parser.rb', line 10 def root @root end |
Class Method Details
.parse(record, *args) ⇒ Krikri::Parser
Instantiates a parser object to wrap the record. Returns the record as is if it is already parsed.
27 28 29 |
# File 'lib/krikri/parser.rb', line 27 def self.parse(record, *args) record.is_a?(Krikri::Parser) ? record : new(record, *args) end |
Instance Method Details
#local_name ⇒ String
Returns the local_name of the OriginalRecord wrapped by this parser.
34 35 36 |
# File 'lib/krikri/parser.rb', line 34 def local_name record.local_name end |