-
-
Save regedarek/4f9a62860e5a91d0de57 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Code below works for me | |
cars_types = [ | |
{"car_type"=>"11", "car_features"=>"21"}, # car one | |
{"car_type"=>"12", "car_features"=>"22"} # car two | |
] | |
# cars_results = [ | |
# {"car_badge"=>"typical", "car_doors"=>"5"}, # car one | |
# {"car_badge"=>"typical", "car_doors"=>"3"} # car two | |
# ] | |
... | |
class CarRental | |
attr_accessor :car_type, :car_features, :car_badge, :car_doors | |
def initialize(data) | |
@one = data["car_type"] | |
@two = data["car_features"] | |
# @three = data["car_badge"] | |
# @four = data["car_doors"] | |
end | |
class << self | |
def find(info) | |
array_1.map do |data| | |
CarRental.new(data) | |
end | |
end | |
... |
This should be something like:
[array_1, array_2].map do |data|
CarRental.new(data)
end
https://github.com/thoughtfusion/suitcase/blob/master/lib/suitcase/car_rental.rb
Link to gem. And documentation => http://developer.hotwire.com/docs/read/Rental_Car_Shopping_API
Basicaly I would like to extend
def initialize(data)
@seating = data["CarTypeSeating"]
@type_name = data["CarTypeName"]
@type_code = data["CarTypeCode"]
@possible_features = data["PossibleFeatures"].split(", ")
@possible_models = data["PossibleModels"].split(", ")
end
by new params from parsed["Result"]
array
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now I would like to add next array to this: