Class: Unit::Types::Address
- Inherits:
-
Object
- Object
- Unit::Types::Address
- Defined in:
- lib/unit-ruby/types/address.rb
Instance Attribute Summary collapse
-
#city ⇒ Object
readonly
Returns the value of attribute city.
-
#country ⇒ Object
readonly
Returns the value of attribute country.
-
#postal_code ⇒ Object
readonly
Returns the value of attribute postal_code.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#street ⇒ Object
readonly
Returns the value of attribute street.
-
#street2 ⇒ Object
readonly
Returns the value of attribute street2.
Class Method Summary collapse
Instance Method Summary collapse
- #as_json_api ⇒ Object
-
#initialize(street:, city:, state:, postal_code:, country:, street2: nil) ⇒ Address
constructor
A new instance of Address.
Constructor Details
#initialize(street:, city:, state:, postal_code:, country:, street2: nil) ⇒ Address
Returns a new instance of Address.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/unit-ruby/types/address.rb', line 6 def initialize( street:, city:, state:, postal_code:, country:, street2: nil ) @street = street @street2 = street2 @city = city @state = state @postal_code = postal_code @country = country end |
Instance Attribute Details
#city ⇒ Object (readonly)
Returns the value of attribute city.
4 5 6 |
# File 'lib/unit-ruby/types/address.rb', line 4 def city @city end |
#country ⇒ Object (readonly)
Returns the value of attribute country.
4 5 6 |
# File 'lib/unit-ruby/types/address.rb', line 4 def country @country end |
#postal_code ⇒ Object (readonly)
Returns the value of attribute postal_code.
4 5 6 |
# File 'lib/unit-ruby/types/address.rb', line 4 def postal_code @postal_code end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
4 5 6 |
# File 'lib/unit-ruby/types/address.rb', line 4 def state @state end |
#street ⇒ Object (readonly)
Returns the value of attribute street.
4 5 6 |
# File 'lib/unit-ruby/types/address.rb', line 4 def street @street end |
#street2 ⇒ Object (readonly)
Returns the value of attribute street2.
4 5 6 |
# File 'lib/unit-ruby/types/address.rb', line 4 def street2 @street2 end |
Class Method Details
.cast(val) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/unit-ruby/types/address.rb', line 22 def self.cast(val) return val if val.is_a? self return nil if val.nil? new( street: val[:street], street2: val[:street2], city: val[:city], state: val[:state], postal_code: val[:postal_code], country: val[:country] ) end |
Instance Method Details
#as_json_api ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/unit-ruby/types/address.rb', line 36 def as_json_api { street: street, street2: street2, city: city, state: state, postal_code: postal_code, country: country }.compact end |