Class: SeametrixRuby::Models::Port

Inherits:
Object
  • Object
show all
Defined in:
lib/seametrix_ruby/models/port.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Port

Returns a new instance of Port.



11
12
13
14
15
16
17
18
# File 'lib/seametrix_ruby/models/port.rb', line 11

def initialize(attributes =  {})
  @port_name = attributes[:port_name]
  @port_code = attributes[:port_code]
  @country = attributes[:country]

  self.longitude = attributes[:longitude].to_f
  self.latitude = attributes[:latitude].to_f
end

Instance Attribute Details

#countryObject

Returns the value of attribute country.



8
9
10
# File 'lib/seametrix_ruby/models/port.rb', line 8

def country
  @country
end

#latitudeObject

Returns the value of attribute latitude.



9
10
11
# File 'lib/seametrix_ruby/models/port.rb', line 9

def latitude
  @latitude
end

#longitudeObject

Returns the value of attribute longitude.



9
10
11
# File 'lib/seametrix_ruby/models/port.rb', line 9

def longitude
  @longitude
end

#port_codeObject

Returns the value of attribute port_code.



8
9
10
# File 'lib/seametrix_ruby/models/port.rb', line 8

def port_code
  @port_code
end

#port_nameObject

Returns the value of attribute port_name.



8
9
10
# File 'lib/seametrix_ruby/models/port.rb', line 8

def port_name
  @port_name
end

#waypointObject (readonly)

Returns the value of attribute waypoint.



9
10
11
# File 'lib/seametrix_ruby/models/port.rb', line 9

def waypoint
  @waypoint
end

Class Method Details

.from_json(json_string) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/seametrix_ruby/models/port.rb', line 20

def self.from_json(json_string)
  json = MultiJson.load(json_string)

  new(port_name: json['portName'],
      port_code: json['portCode'],
      country: json['country'],
      longitude: json['longitude'].to_f,
      latitude: json['latitude'].to_f)
end