Class: Gas_station
- Inherits:
-
Object
- Object
- Gas_station
- Defined in:
- lib/gas_station.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#detail_url ⇒ Object
Returns the value of attribute detail_url.
-
#name ⇒ Object
Returns the value of attribute name.
-
#new_array ⇒ Object
Returns the value of attribute new_array.
-
#price ⇒ Object
Returns the value of attribute price.
-
#rating ⇒ Object
Returns the value of attribute rating.
Class Method Summary collapse
Instance Method Summary collapse
- #add_more_info(data) ⇒ Object
-
#initialize(name:, address:, price:, detail_url:) ⇒ Gas_station
constructor
A new instance of Gas_station.
Constructor Details
#initialize(name:, address:, price:, detail_url:) ⇒ Gas_station
Returns a new instance of Gas_station.
5 6 7 8 9 10 |
# File 'lib/gas_station.rb', line 5 def initialize(name:,address:,price:, detail_url:) @name = name @address = address @price = price @detail_url = detail_url end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
3 4 5 |
# File 'lib/gas_station.rb', line 3 def address @address end |
#detail_url ⇒ Object
Returns the value of attribute detail_url.
3 4 5 |
# File 'lib/gas_station.rb', line 3 def detail_url @detail_url end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/gas_station.rb', line 3 def name @name end |
#new_array ⇒ Object
Returns the value of attribute new_array.
3 4 5 |
# File 'lib/gas_station.rb', line 3 def new_array @new_array end |
#price ⇒ Object
Returns the value of attribute price.
3 4 5 |
# File 'lib/gas_station.rb', line 3 def price @price end |
#rating ⇒ Object
Returns the value of attribute rating.
3 4 5 |
# File 'lib/gas_station.rb', line 3 def @rating end |
Class Method Details
.all ⇒ Object
27 28 29 |
# File 'lib/gas_station.rb', line 27 def self.all @@all.sort_by{|gas_station| gas_station.price } end |
.create_gas_station_from_data(array_of_gas_station) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/gas_station.rb', line 13 def self.create_gas_station_from_data(array_of_gas_station) array_of_gas_station.each do |gas_station| gas_object =self.new(gas_station) @@all << gas_object if gas_object.price end end |
Instance Method Details
#add_more_info(data) ⇒ Object
21 22 23 24 |
# File 'lib/gas_station.rb', line 21 def add_more_info(data) the_gas_station = self data.each {|key,val| the_gas_station.send("#{key}=",val) } end |