Class: Top25::Place

Inherits:
Object
  • Object
show all
Defined in:
lib/top25/place.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attr_hash) ⇒ Place

“”, location: “”, :address =>“”



4
5
6
7
8
9
# File 'lib/top25/place.rb', line 4

def initialize(attr_hash)   #{name: "", location: "", :address =>""}
  attr_hash.each do |attribute, v|
    self.send("#{attribute}=",v)
  end
  @@all << self
end

Instance Attribute Details

#locationObject

Returns the value of attribute location.



2
3
4
# File 'lib/top25/place.rb', line 2

def location
  @location
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/top25/place.rb', line 2

def name
  @name
end

#numObject

Returns the value of attribute num.



2
3
4
# File 'lib/top25/place.rb', line 2

def num
  @num
end

#urlObject

Returns the value of attribute url.



2
3
4
# File 'lib/top25/place.rb', line 2

def url
  @url
end

Class Method Details

.allObject



11
12
13
# File 'lib/top25/place.rb', line 11

def self.all
  @@all
end

.create_from_collection(arr) ⇒ Object



15
16
17
18
19
# File 'lib/top25/place.rb', line 15

def self.create_from_collection(arr)
  arr.each do |hash|
    self.new(hash)
  end
end