Class: UKPostcode::ParserChain
- Inherits:
-
Object
- Object
- UKPostcode::ParserChain
- Defined in:
- lib/uk_postcode/parser_chain.rb
Instance Method Summary collapse
-
#initialize(*parsers) ⇒ ParserChain
constructor
A new instance of ParserChain.
- #parse(str) ⇒ Object
Constructor Details
#initialize(*parsers) ⇒ ParserChain
Returns a new instance of ParserChain.
3 4 5 |
# File 'lib/uk_postcode/parser_chain.rb', line 3 def initialize(*parsers) @parsers = parsers end |
Instance Method Details
#parse(str) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/uk_postcode/parser_chain.rb', line 7 def parse(str) @parsers.each do |klass| parsed = klass.parse(str) return parsed if parsed end nil end |