Class: Incognia::Address
- Inherits:
-
Object
- Object
- Incognia::Address
- Defined in:
- lib/incognia_api/address.rb
Defined Under Namespace
Classes: Coordinates, Line, Structured
Constant Summary collapse
- FORMATS =
[:line, :coordinates, :structured].freeze
Instance Attribute Summary collapse
-
#coordinates ⇒ Object
readonly
Returns the value of attribute coordinates.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#structured ⇒ Object
readonly
Returns the value of attribute structured.
Instance Method Summary collapse
-
#initialize(line: nil, coordinates: {}, structured: {}) ⇒ Address
constructor
A new instance of Address.
- #to_hash ⇒ Object
Constructor Details
#initialize(line: nil, coordinates: {}, structured: {}) ⇒ Address
Returns a new instance of Address.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/incognia_api/address.rb', line 70 def initialize(line: nil, coordinates: {}, structured: {}) coordinates = Util.symbolize_names(coordinates) structured = Util.symbolize_names(structured) if line.nil? && coordinates.empty? && structured.empty? raise ArgumentError.new( "missing keyword: should be one of #{FORMATS.join(', ')}" ) end @line = build_line(line) @coordinates = build_coordinates(coordinates) @structured = build_structured(structured) end |
Instance Attribute Details
#coordinates ⇒ Object (readonly)
Returns the value of attribute coordinates.
5 6 7 |
# File 'lib/incognia_api/address.rb', line 5 def coordinates @coordinates end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
5 6 7 |
# File 'lib/incognia_api/address.rb', line 5 def line @line end |
#structured ⇒ Object (readonly)
Returns the value of attribute structured.
5 6 7 |
# File 'lib/incognia_api/address.rb', line 5 def structured @structured end |
Instance Method Details
#to_hash ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/incognia_api/address.rb', line 85 def to_hash hash = {} hash.merge!(@line.to_hash) hash.merge!(@coordinates.to_hash) hash.merge!(@structured.to_hash) hash end |