Class: GenesisRuby::Parsers::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/genesis_ruby/parsers/base.rb

Overview

Contract for every parser abstraction

Direct Known Subclasses

Json, Xml

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



10
11
12
13
# File 'lib/genesis_ruby/parsers/base.rb', line 10

def initialize
  @structure         = {}
  @root_node_skipped = false
end

Instance Attribute Details

#root_node_skippedObject (readonly)

Returns the value of attribute root_node_skipped.



8
9
10
# File 'lib/genesis_ruby/parsers/base.rb', line 8

def root_node_skipped
  @root_node_skipped
end

#structureObject (readonly)

Returns the value of attribute structure.



8
9
10
# File 'lib/genesis_ruby/parsers/base.rb', line 8

def structure
  @structure
end

Instance Method Details

#parse_document(document) ⇒ Object

Parse given document to Hash Structuce

Raises:

  • (NotImplementedError)


16
17
18
# File 'lib/genesis_ruby/parsers/base.rb', line 16

def parse_document(document)
  raise NotImplementedError, 'Parse Document must be implemented'
end

#skip_root_nodeObject

Indicates that the Root element will not be included in the generated Object



21
22
23
# File 'lib/genesis_ruby/parsers/base.rb', line 21

def skip_root_node
  @root_node_skipped = true
end