Class: Baykit::BayServer::Util::Cities
- Inherits:
-
Object
- Object
- Baykit::BayServer::Util::Cities
- Defined in:
- lib/baykit/bayserver/common/cities.rb
Instance Attribute Summary collapse
-
#any_city ⇒ Object
readonly
Returns the value of attribute any_city.
-
#cities ⇒ Object
readonly
Returns the value of attribute cities.
Instance Method Summary collapse
- #add(c) ⇒ Object
- #find_city(name) ⇒ Object
-
#initialize ⇒ Cities
constructor
A new instance of Cities.
Constructor Details
#initialize ⇒ Cities
Returns a new instance of Cities.
9 10 11 12 |
# File 'lib/baykit/bayserver/common/cities.rb', line 9 def initialize @any_city = nil @cities = [] end |
Instance Attribute Details
#any_city ⇒ Object (readonly)
Returns the value of attribute any_city.
6 7 8 |
# File 'lib/baykit/bayserver/common/cities.rb', line 6 def any_city @any_city end |
#cities ⇒ Object (readonly)
Returns the value of attribute cities.
7 8 9 |
# File 'lib/baykit/bayserver/common/cities.rb', line 7 def cities @cities end |
Instance Method Details
#add(c) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/baykit/bayserver/common/cities.rb', line 14 def add(c) if c.name == "*" @any_city = c else @cities << c end end |
#find_city(name) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/baykit/bayserver/common/cities.rb', line 23 def find_city(name) # Check exact match @cities.each do |city| if city.name == name return city end end return @any_city end |