Class: TouristGuide::Tour
- Inherits:
-
Object
- Object
- TouristGuide::Tour
- Defined in:
- lib/tourist_guide/tour.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#description ⇒ Object
Returns the value of attribute description.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
- .all ⇒ Object
-
.clear ⇒ Object
to delete duplicated & previous lists.
- .create_from_collection(array) ⇒ Object
Instance Method Summary collapse
-
#initialize(attr_hash) ⇒ Tour
constructor
A new instance of Tour.
Constructor Details
#initialize(attr_hash) ⇒ Tour
Returns a new instance of Tour.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/tourist_guide/tour.rb', line 5 def initialize(attr_hash) # attr_hash.each do |attribute, v| # self.name= attribute(:name) # self.address= attribute(:address) # self.description= attribute(:description) # self.send "name=", "John Smith" # equivalent to # self.name = "John Smith" attr_hash.each do |attribute, v| self.send("#{attribute}=",v) end @@all << self end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
2 3 4 |
# File 'lib/tourist_guide/tour.rb', line 2 def address @address end |
#description ⇒ Object
Returns the value of attribute description.
2 3 4 |
# File 'lib/tourist_guide/tour.rb', line 2 def description @description end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/tourist_guide/tour.rb', line 2 def name @name end |
Class Method Details
.all ⇒ Object
22 23 24 |
# File 'lib/tourist_guide/tour.rb', line 22 def self.all @@all end |
.clear ⇒ Object
to delete duplicated & previous lists
33 34 35 |
# File 'lib/tourist_guide/tour.rb', line 33 def self.clear @@all =[] end |
.create_from_collection(array) ⇒ Object
26 27 28 29 30 |
# File 'lib/tourist_guide/tour.rb', line 26 def self.create_from_collection(array) array.each do |hash| self.new(hash) end end |