Class: Auspost::Postie::Suburb
- Inherits:
-
Object
- Object
- Auspost::Postie::Suburb
- Defined in:
- lib/auspost/postie.rb
Instance Method Summary collapse
- #eql?(attrs) ⇒ Boolean
-
#initialize(attrs) ⇒ Suburb
constructor
A new instance of Suburb.
- #postcode?(attrs) ⇒ Boolean
- #state?(attrs) ⇒ Boolean
- #suburb?(attrs) ⇒ Boolean
- #to_i(attrs) ⇒ Object
Constructor Details
#initialize(attrs) ⇒ Suburb
Returns a new instance of Suburb.
38 39 40 41 42 |
# File 'lib/auspost/postie.rb', line 38 def initialize(attrs) @suburb = attrs[:suburb].downcase @postcode = attrs[:postcode].to_i @state = attrs[:state].downcase end |
Instance Method Details
#eql?(attrs) ⇒ Boolean
56 57 58 |
# File 'lib/auspost/postie.rb', line 56 def eql?(attrs) suburb?(attrs) && postcode?(attrs) && state?(attrs) end |
#postcode?(attrs) ⇒ Boolean
52 53 54 |
# File 'lib/auspost/postie.rb', line 52 def postcode?(attrs) attrs[:postcode].to_i == @postcode end |
#state?(attrs) ⇒ Boolean
48 49 50 |
# File 'lib/auspost/postie.rb', line 48 def state?(attrs) attrs[:state].downcase == @state.downcase end |
#suburb?(attrs) ⇒ Boolean
44 45 46 |
# File 'lib/auspost/postie.rb', line 44 def suburb?(attrs) attrs[:suburb].downcase == @suburb end |
#to_i(attrs) ⇒ Object
60 61 62 63 64 |
# File 'lib/auspost/postie.rb', line 60 def to_i(attrs) (suburb?(attrs) ? 1 : 0) + (state?(attrs) ? 1 : 0) + (postcode?(attrs) ? 1 : 0) end |