Class: Route

Inherits:
Entity show all
Defined in:
lib/ttr/entities/route.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

#citiesObject

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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


21
22
23
# File 'lib/ttr/entities/route.rb', line 21

def claimed_by_player? (player)
  @obj.player_obj == Player.object(player)
end

#colorObject

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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


46
47
48
# File 'lib/ttr/entities/route.rb', line 46

def grey?
  @obj.color == :grey
end

#lengthObject

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.

Returns:

  • (Boolean)


59
60
61
# File 'lib/ttr/entities/route.rb', line 59

def match? (color)
  [color, :grey].include?(@obj.color)
end

#pointsObject

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.

Returns:

  • (Boolean)


71
72
73
# File 'lib/ttr/entities/route.rb', line 71

def unclaimed?
  @obj.player_obj == nil
end