Class: Ellington::Connection
- Inherits:
-
Object
- Object
- Ellington::Connection
- Defined in:
- lib/ellington/connection.rb
Instance Attribute Summary collapse
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#states ⇒ Object
readonly
Returns the value of attribute states.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(line, type, *states) ⇒ Connection
constructor
A new instance of Connection.
- #required?(passenger) ⇒ Boolean
Constructor Details
#initialize(line, type, *states) ⇒ Connection
Returns a new instance of Connection.
5 6 7 8 9 |
# File 'lib/ellington/connection.rb', line 5 def initialize(line, type, *states) @line = line @type = type @states = Ellington::Target.new(*states) end |
Instance Attribute Details
#line ⇒ Object (readonly)
Returns the value of attribute line.
3 4 5 |
# File 'lib/ellington/connection.rb', line 3 def line @line end |
#states ⇒ Object (readonly)
Returns the value of attribute states.
3 4 5 |
# File 'lib/ellington/connection.rb', line 3 def states @states end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/ellington/connection.rb', line 3 def type @type end |
Instance Method Details
#required?(passenger) ⇒ Boolean
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ellington/connection.rb', line 11 def required?(passenger) return false if line.boarded?(passenger) if type == :if_any return states.satisfied?(passenger) end if type == :if_all return (passenger.state_history & states).length == states.length end false end |