Class: UKPostcode::ParserChain

Inherits:
Object
  • Object
show all
Defined in:
lib/uk_postcode/parser_chain.rb

Instance Method Summary collapse

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