Class: TicketObject
- Inherits:
-
Object
- Object
- TicketObject
- Defined in:
- lib/ttr/objects/ticket.rb
Overview
Copyright © 2011 Jesse Sielaff
Instance Attribute Summary collapse
-
#city_objs ⇒ Object
readonly
Returns the value of attribute city_objs.
-
#points ⇒ Object
readonly
Returns the value of attribute points.
Instance Method Summary collapse
-
#completed?(route_objs) ⇒ Boolean
Returns true if the Ticket is completed by any combination of the given Routes, false otherwise.
-
#initialize(points, city_objs) ⇒ TicketObject
constructor
A new instance of TicketObject.
Constructor Details
#initialize(points, city_objs) ⇒ TicketObject
Returns a new instance of TicketObject.
7 8 9 10 |
# File 'lib/ttr/objects/ticket.rb', line 7 def initialize (points, city_objs) @city_objs = city_objs @points = points end |
Instance Attribute Details
#city_objs ⇒ Object (readonly)
Returns the value of attribute city_objs.
12 13 14 |
# File 'lib/ttr/objects/ticket.rb', line 12 def city_objs @city_objs end |
#points ⇒ Object (readonly)
Returns the value of attribute points.
12 13 14 |
# File 'lib/ttr/objects/ticket.rb', line 12 def points @points end |
Instance Method Details
#completed?(route_objs) ⇒ Boolean
Returns true if the Ticket is completed by any combination of the given Routes, false otherwise.
17 18 19 20 21 22 23 |
# File 'lib/ttr/objects/ticket.rb', line 17 def completed? (route_objs) c1, c2 = city_objs return false unless route_objs.any? {|obj| obj.into?(c1) } return false unless route_objs.any? {|obj| obj.into?(c2) } c1.connected_using?(c2, route_objs) end |