Class: Ellington::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/ellington/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line, *states, strict: false) ⇒ Connection

Returns a new instance of Connection.



5
6
7
8
9
# File 'lib/ellington/connection.rb', line 5

def initialize(line, *states, strict: false)
  @line = line
  @states = Ellington::Target.new(*states)
  @strict = strict
end

Instance Attribute Details

#lineObject (readonly)

Returns the value of attribute line.



3
4
5
# File 'lib/ellington/connection.rb', line 3

def line
  @line
end

#statesObject (readonly)

Returns the value of attribute states.



3
4
5
# File 'lib/ellington/connection.rb', line 3

def states
  @states
end

#strictObject (readonly)

Returns the value of attribute strict.



3
4
5
# File 'lib/ellington/connection.rb', line 3

def strict
  @strict
end

Instance Method Details

#required?(passenger) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
# File 'lib/ellington/connection.rb', line 11

def required?(passenger)
  return false if line.boarded?(passenger)
  return (passenger.state_history & states).length == states.length if strict
  states.satisfied?(passenger)
end