Class: City

Inherits:
Entity show all
Defined in:
lib/ttr/entities/city.rb

Overview

Copyright © 2011 Jesse Sielaff

Instance Method Summary collapse

Methods inherited from Entity

inherited, #initialize

Constructor Details

This class inherits a constructor from Entity

Instance Method Details

#connected?(city) ⇒ Boolean

Returns true if the two Cities are connected by a single direct Route, false otherwise.

Returns:

  • (Boolean)


10
11
12
# File 'lib/ttr/entities/city.rb', line 10

def connected? (city)
  @obj.connected?(City.object(city))
end

#connected_citiesObject

Returns an Array of Cities connected to the City by a single direct Route.



16
17
18
# File 'lib/ttr/entities/city.rb', line 16

def connected_cities
  City.entities(@obj.connected_city_objs)
end

#nameObject

Returns the name of the City as a Symbol.



22
23
24
# File 'lib/ttr/entities/city.rb', line 22

def name
  @obj.name
end

#routesObject

Returns an Array of Routes leading into and out of the City.



28
29
30
# File 'lib/ttr/entities/city.rb', line 28

def routes
  Route.entities(@obj.route_objs)
end

#unclaimed_routesObject

Returns an Array of Routes leading into and out of the City that are not claimed by any Player.



35
36
37
# File 'lib/ttr/entities/city.rb', line 35

def unclaimed_routes
  Route.entities(@obj.route_objs.reject {|obj| obj.player_obj })
end