Class: Auspost::Postie::Suburb

Inherits:
Object
  • Object
show all
Defined in:
lib/auspost/postie.rb

Instance Method Summary collapse

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

Returns:

  • (Boolean)

56
57
58
# File 'lib/auspost/postie.rb', line 56

def eql?(attrs)
  suburb?(attrs) && postcode?(attrs) && state?(attrs)
end

#postcode?(attrs) ⇒ Boolean

Returns:

  • (Boolean)

52
53
54
# File 'lib/auspost/postie.rb', line 52

def postcode?(attrs)
  attrs[:postcode].to_i == @postcode
end

#state?(attrs) ⇒ Boolean

Returns:

  • (Boolean)

48
49
50
# File 'lib/auspost/postie.rb', line 48

def state?(attrs)
  attrs[:state].downcase == @state.downcase
end

#suburb?(attrs) ⇒ Boolean

Returns:

  • (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