Class: SeametrixRuby::Requests::RouteRequest
- Inherits:
-
Object
- Object
- SeametrixRuby::Requests::RouteRequest
- Defined in:
- lib/seametrix_ruby/requests/route_request.rb
Constant Summary collapse
- DOUBLE_ATTRS =
[:start_lon, :start_lat, :end_lon, :end_lat].freeze
- INTEGER_ATTRS =
[:great_circle_interval, :seca_avoidance, :asl_compliance].freeze
- ARRAY_ATTRS =
[:allowed_areas].freeze
Instance Attribute Summary collapse
-
#allowed_areas ⇒ Object
Returns the value of attribute allowed_areas.
-
#asl_compliance ⇒ Object
Returns the value of attribute asl_compliance.
-
#end_lat ⇒ Object
Returns the value of attribute end_lat.
-
#end_lon ⇒ Object
Returns the value of attribute end_lon.
-
#end_port_code ⇒ Object
Returns the value of attribute end_port_code.
-
#great_circle_interval ⇒ Object
Returns the value of attribute great_circle_interval.
-
#seca_avoidance ⇒ Object
Returns the value of attribute seca_avoidance.
-
#start_lat ⇒ Object
Returns the value of attribute start_lat.
-
#start_lon ⇒ Object
Returns the value of attribute start_lon.
-
#start_port_code ⇒ Object
Returns the value of attribute start_port_code.
Class Method Summary collapse
- .attributes ⇒ Object
- .build(port_start:, port_end:, great_circle_interval: nil, allowed_areas: [], seca_avoidance: nil, asl_compliance: nil) ⇒ Object
- .from_json(json_string) ⇒ Object
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ RouteRequest
constructor
A new instance of RouteRequest.
- #to_params ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ RouteRequest
Returns a new instance of RouteRequest.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/seametrix_ruby/requests/route_request.rb', line 21 def initialize(attributes = {}) if attributes[:start_lon] && attributes[:start_lat] @start_lon = attributes[:start_lon] @start_lat = attributes[:start_lat] else @start_port_code = attributes[:start_port_code] end if attributes[:end_lon] && attributes[:end_lat] @end_lon = attributes[:end_lon] @end_lat = attributes[:end_lat] else @end_port_code = attributes[:end_port_code] end @great_circle_interval = attributes[:great_circle_interval] @allowed_areas = attributes[:allowed_areas] @seca_avoidance = attributes[:seca_avoidance] @asl_compliance = attributes[:asl_compliance] end |
Instance Attribute Details
#allowed_areas ⇒ Object
Returns the value of attribute allowed_areas.
10 11 12 |
# File 'lib/seametrix_ruby/requests/route_request.rb', line 10 def allowed_areas @allowed_areas end |
#asl_compliance ⇒ Object
Returns the value of attribute asl_compliance.
10 11 12 |
# File 'lib/seametrix_ruby/requests/route_request.rb', line 10 def asl_compliance @asl_compliance end |
#end_lat ⇒ Object
Returns the value of attribute end_lat.
10 11 12 |
# File 'lib/seametrix_ruby/requests/route_request.rb', line 10 def end_lat @end_lat end |
#end_lon ⇒ Object
Returns the value of attribute end_lon.
10 11 12 |
# File 'lib/seametrix_ruby/requests/route_request.rb', line 10 def end_lon @end_lon end |
#end_port_code ⇒ Object
Returns the value of attribute end_port_code.
10 11 12 |
# File 'lib/seametrix_ruby/requests/route_request.rb', line 10 def end_port_code @end_port_code end |
#great_circle_interval ⇒ Object
Returns the value of attribute great_circle_interval.
10 11 12 |
# File 'lib/seametrix_ruby/requests/route_request.rb', line 10 def great_circle_interval @great_circle_interval end |
#seca_avoidance ⇒ Object
Returns the value of attribute seca_avoidance.
10 11 12 |
# File 'lib/seametrix_ruby/requests/route_request.rb', line 10 def seca_avoidance @seca_avoidance end |
#start_lat ⇒ Object
Returns the value of attribute start_lat.
10 11 12 |
# File 'lib/seametrix_ruby/requests/route_request.rb', line 10 def start_lat @start_lat end |
#start_lon ⇒ Object
Returns the value of attribute start_lon.
10 11 12 |
# File 'lib/seametrix_ruby/requests/route_request.rb', line 10 def start_lon @start_lon end |
#start_port_code ⇒ Object
Returns the value of attribute start_port_code.
10 11 12 |
# File 'lib/seametrix_ruby/requests/route_request.rb', line 10 def start_port_code @start_port_code end |
Class Method Details
.attributes ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/seametrix_ruby/requests/route_request.rb', line 76 def self.attributes [ :start_lon, :start_lat, :start_port_code, :end_lon, :end_lat, :end_port_code, :great_circle_interval, :allowed_areas, :seca_avoidance, :asl_compliance ].freeze end |
.build(port_start:, port_end:, great_circle_interval: nil, allowed_areas: [], seca_avoidance: nil, asl_compliance: nil) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/seametrix_ruby/requests/route_request.rb', line 42 def self.build(port_start:, port_end:, great_circle_interval: nil, allowed_areas: [], seca_avoidance: nil, asl_compliance: nil) new(start_lon: port_start.longitude.to_f, start_lat: port_start.latitude.to_f, start_port_code: port_start.port_code, end_lon: port_end.longitude.to_f, end_lat: port_end.latitude.to_f, end_port_code: port_end.port_code, great_circle_interval: great_circle_interval, allowed_areas: allowed_areas, seca_avoidance: seca_avoidance, asl_compliance: asl_compliance) end |
.from_json(json_string) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/seametrix_ruby/requests/route_request.rb', line 61 def self.from_json(json_string) json = MultiJson.load(json_string) new(start_lon: json['startLon'].to_f, start_lat: json['startLat'].to_f, start_port_code: json['startPortCode'], end_lon: json['endLon'].to_f, end_lat: json['endLat'].to_f, end_port_code: json['endPortCode'], great_circle_interval: json['greatCircleInterval'], allowed_areas: json['allowedAreas'], seca_avoidance: json['secaAvoidance'], asl_compliance: json['aslCompliance']) end |
Instance Method Details
#to_params ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/seametrix_ruby/requests/route_request.rb', line 91 def to_params params = {} self.class.attributes.each do |key| value = send key next unless value hash_key = key.to_s.camelize hash_key = [hash_key[0].downcase, hash_key[1..hash_key.size - 1]].join params[hash_key] = if DOUBLE_ATTRS.include?(key) value.to_f elsif INTEGER_ATTRS.include?(key) value.to_i else value end end params end |