Class: Castiel::Parsers::BaseParser
- Inherits:
-
Object
- Object
- Castiel::Parsers::BaseParser
- Defined in:
- lib/castiel/parsers/base_parser.rb
Direct Known Subclasses
Instance Method Summary collapse
- #<<(element) ⇒ Object
- #parse(elements) ⇒ Object
- #parse_element(element, context = nil) ⇒ Object
- #parsers ⇒ Object
Instance Method Details
#<<(element) ⇒ Object
9 10 11 |
# File 'lib/castiel/parsers/base_parser.rb', line 9 def <<(element) parsers << element end |
#parse(elements) ⇒ Object
13 14 15 16 |
# File 'lib/castiel/parsers/base_parser.rb', line 13 def parse(elements) elements = elements.split ' ' if elements.is_a? String elements.collect{|element| parse_element element} end |
#parse_element(element, context = nil) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/castiel/parsers/base_parser.rb', line 18 def parse_element(element, context = nil) parsers.each do |parser| return parser.evaluate(element, context) if parser.match? element end nil end |
#parsers ⇒ Object
5 6 7 |
# File 'lib/castiel/parsers/base_parser.rb', line 5 def parsers @parsers ||= [] end |