Class: Route
Overview
Copyright © 2011 Jesse Sielaff
Instance Method Summary collapse
-
#cities ⇒ Object
Returns an Array of the two Cities at either end of the Route.
-
#claimed? ⇒ Boolean
Returns true if any Player has claimed the Route, false otherwise.
-
#claimed_by_player?(player) ⇒ Boolean
Returns true if the given Player has claimed the route, false otherwise.
-
#color ⇒ Object
Returns the color of the Route as a Symbol.
-
#color? ⇒ Boolean
Returns false if the color of the Route is :grey, true otherwise.
-
#exact_match?(color) ⇒ Boolean
Returns true if the Route is the exact same color as the given color, false otherwise.
-
#grey? ⇒ Boolean
Returns true if the color of the Route is :grey, false otherwise.
-
#length ⇒ Object
Returns the length of the Route.
-
#match?(color) ⇒ Boolean
Returns true if the given color represents a color match with the Route, false otherwise.
-
#points ⇒ Object
Returns the point value of the Route.
-
#unclaimed? ⇒ Boolean
Returns true if the Route is unclaimed, false otherwise.
Methods inherited from Entity
Constructor Details
This class inherits a constructor from Entity
Instance Method Details
#cities ⇒ Object
Returns an Array of the two Cities at either end of the Route.
9 10 11 |
# File 'lib/ttr/entities/route.rb', line 9 def cities City.entities(@obj.city_objs) end |
#claimed? ⇒ Boolean
Returns true if any Player has claimed the Route, false otherwise.
15 16 17 |
# File 'lib/ttr/entities/route.rb', line 15 def claimed? @obj.player_obj != nil end |
#claimed_by_player?(player) ⇒ Boolean
Returns true if the given Player has claimed the route, false otherwise.
21 22 23 |
# File 'lib/ttr/entities/route.rb', line 21 def claimed_by_player? (player) @obj.player_obj == Player.object(player) end |
#color ⇒ Object
Returns the color of the Route as a Symbol.
27 28 29 |
# File 'lib/ttr/entities/route.rb', line 27 def color @obj.color end |
#color? ⇒ Boolean
Returns false if the color of the Route is :grey, true otherwise.
33 34 35 |
# File 'lib/ttr/entities/route.rb', line 33 def color? @obj.color != :grey end |
#exact_match?(color) ⇒ Boolean
Returns true if the Route is the exact same color as the given color, false otherwise.
40 41 42 |
# File 'lib/ttr/entities/route.rb', line 40 def exact_match? (color) @obj.color == color end |
#grey? ⇒ Boolean
Returns true if the color of the Route is :grey, false otherwise.
46 47 48 |
# File 'lib/ttr/entities/route.rb', line 46 def grey? @obj.color == :grey end |
#length ⇒ Object
Returns the length of the Route.
52 53 54 |
# File 'lib/ttr/entities/route.rb', line 52 def length @obj.length end |
#match?(color) ⇒ Boolean
Returns true if the given color represents a color match with the Route, false otherwise. The color :grey matches every color.
59 60 61 |
# File 'lib/ttr/entities/route.rb', line 59 def match? (color) [color, :grey].include?(@obj.color) end |
#points ⇒ Object
Returns the point value of the Route.
65 66 67 |
# File 'lib/ttr/entities/route.rb', line 65 def points @obj.points end |
#unclaimed? ⇒ Boolean
Returns true if the Route is unclaimed, false otherwise.
71 72 73 |
# File 'lib/ttr/entities/route.rb', line 71 def unclaimed? @obj.player_obj == nil end |