Class: GenesisRuby::Parser
- Inherits:
-
Object
- Object
- GenesisRuby::Parser
- Defined in:
- lib/genesis_ruby/parser.rb
Overview
Parser handler
Constant Summary collapse
- XML =
XML Parser
'xml'- JSON =
JSON Parser
'json'
Instance Method Summary collapse
-
#initialize(response_interface) ⇒ Parser
constructor
Initialize the Parser Interface based on the Response requirements.
-
#parse_document(document) ⇒ Object
Parse tree-structure into Builder document.
-
#skip_root_node ⇒ Object
Indicates that the Root element will not be included in the generated Object.
-
#structure ⇒ Object
Parsed document.
Constructor Details
#initialize(response_interface) ⇒ Parser
Initialize the Parser Interface based on the Response requirements
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/genesis_ruby/parser.rb', line 18 def initialize(response_interface) case response_interface when XML @parser_context = GenesisRuby::Parsers::Xml.new when JSON @parser_context = GenesisRuby::Parsers::Json.new else raise GenesisRuby::ParserError, 'Invalid Parser interface!' end end |
Instance Method Details
#parse_document(document) ⇒ Object
Parse tree-structure into Builder document
35 36 37 |
# File 'lib/genesis_ruby/parser.rb', line 35 def parse_document(document) parser_context.parse_document(document) end |
#skip_root_node ⇒ Object
Indicates that the Root element will not be included in the generated Object
40 41 42 |
# File 'lib/genesis_ruby/parser.rb', line 40 def skip_root_node parser_context.skip_root_node end |
#structure ⇒ Object
Parsed document
30 31 32 |
# File 'lib/genesis_ruby/parser.rb', line 30 def structure parser_context.structure end |