class Krikri::Parser
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>
Attributes
record[R]
root[R]
Public Class Methods
new(record)
click to toggle source
@param record [Krikri::OriginalRecord] a record whose properties can
be parsed by the parser instance.
# File lib/krikri/parser.rb, line 15 def initialize(record) @record = record end
parse(record, *args)
click to toggle source
Instantiates a parser object to wrap the record. Returns the record as is if it is already parsed.
@param record [Krikri::OriginalRecord, Krikri::Parser] the record to parse @param args [Array, nil] the arguments to pass to the parser instance,
if any
@return [Krikri::Parser] a parsed record object
# File lib/krikri/parser.rb, line 27 def self.parse(record, *args) record.is_a?(Krikri::Parser) ? record : new(record, *args) end
Public Instance Methods
local_name()
click to toggle source
@return [String] the local_name
of the OriginalRecord wrapped by this
parser
# File lib/krikri/parser.rb, line 34 def local_name record.local_name end