Class: Baykit::BayServer::Util::Cities

Inherits:
Object
  • Object
show all
Defined in:
lib/baykit/bayserver/common/cities.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCities

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_cityObject (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

#citiesObject (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