Class: Stadium
- Inherits:
-
Object
- Object
- Stadium
- Defined in:
- lib/fbtxt-pp/models/stadiums.rb
Instance Attribute Summary collapse
-
#city ⇒ Object
readonly
Returns the value of attribute city.
-
#country ⇒ Object
readonly
Returns the value of attribute country.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#street ⇒ Object
readonly
Returns the value of attribute street.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name:, city:, street: nil, country: nil, id: nil) ⇒ Stadium
constructor
A new instance of Stadium.
Constructor Details
#initialize(name:, city:, street: nil, country: nil, id: nil) ⇒ Stadium
Returns a new instance of Stadium.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/fbtxt-pp/models/stadiums.rb', line 24 def initialize( name:, city:, street: nil, country: nil, id: nil) ## name, city_name = norm_stadium( name, city_name: city_name ) if id.nil? ## auto-generate id ## use slug of name plus id_city ## add city name id = slugify( name ) id += '_' + slugify( city ) end @id = id @name = name @city = city @street = street @country = country end |
Instance Attribute Details
#city ⇒ Object (readonly)
Returns the value of attribute city.
20 21 22 |
# File 'lib/fbtxt-pp/models/stadiums.rb', line 20 def city @city end |
#country ⇒ Object (readonly)
Returns the value of attribute country.
20 21 22 |
# File 'lib/fbtxt-pp/models/stadiums.rb', line 20 def country @country end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
20 21 22 |
# File 'lib/fbtxt-pp/models/stadiums.rb', line 20 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
20 21 22 |
# File 'lib/fbtxt-pp/models/stadiums.rb', line 20 def name @name end |
#street ⇒ Object (readonly)
Returns the value of attribute street.
20 21 22 |
# File 'lib/fbtxt-pp/models/stadiums.rb', line 20 def street @street end |
Class Method Details
.build(h) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/fbtxt-pp/models/stadiums.rb', line 5 def self.build( h ) if h['name'].nil? puts "stadium without name:" pp h exit 1 end new( name: h['name'], city: h['city'], country: h['country'], street: h['street'] ) end |