Class: Baldr::Parser
- Inherits:
-
Object
- Object
- Baldr::Parser
- Defined in:
- lib/baldr/parser.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#grammar ⇒ Object
readonly
Returns the value of attribute grammar.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#root_type ⇒ Object
readonly
Returns the value of attribute root_type.
-
#separators ⇒ Object
readonly
Returns the value of attribute separators.
Instance Method Summary collapse
- #envelopes ⇒ Object
-
#initialize(input, params = {}) ⇒ Parser
constructor
A new instance of Parser.
- #successful? ⇒ Boolean
- #transactions ⇒ Object
- #validate ⇒ Object
Constructor Details
#initialize(input, params = {}) ⇒ Parser
Returns a new instance of Parser.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/baldr/parser.rb', line 5 def initialize(input, params = {}) @input = input @grammar = params[:grammar] @separators = params[:separators] parse if params[:skip_validation] != true && successful? validate end end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
3 4 5 |
# File 'lib/baldr/parser.rb', line 3 def error @error end |
#grammar ⇒ Object (readonly)
Returns the value of attribute grammar.
3 4 5 |
# File 'lib/baldr/parser.rb', line 3 def grammar @grammar end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
3 4 5 |
# File 'lib/baldr/parser.rb', line 3 def input @input end |
#root_type ⇒ Object (readonly)
Returns the value of attribute root_type.
3 4 5 |
# File 'lib/baldr/parser.rb', line 3 def root_type @root_type end |
#separators ⇒ Object (readonly)
Returns the value of attribute separators.
3 4 5 |
# File 'lib/baldr/parser.rb', line 3 def separators @separators end |
Instance Method Details
#envelopes ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/baldr/parser.rb', line 21 def envelopes if @root_type == :envelope @roots else raise Baldr::Error, "interchange doesn't have envelopes" end end |
#successful? ⇒ Boolean
17 18 19 |
# File 'lib/baldr/parser.rb', line 17 def successful? @error.nil? end |
#transactions ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/baldr/parser.rb', line 29 def transactions if @root_type == :transaction @roots else @roots.map(&:transactions).flatten end end |