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) ⇒ Krikri::Parser
Instantiates a parser object to wrap the record.
Instance Method Summary collapse
-
#initialize(record) ⇒ Parser
constructor
A new instance of 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) ⇒ Krikri::Parser
Instantiates a parser object to wrap the record. Returns the record as is if it is already parsed.
25 26 27 |
# File 'lib/krikri/parser.rb', line 25 def self.parse(record) record.is_a?(Krikri::Parser) ? record : new(record) end |