Class: MovingsignApi::DisplaySpeed

Inherits:
Object
  • Object
show all
Includes:
PrettyKeyable
Defined in:
lib/movingsign_api/commands/internal/display_speed.rb

Overview

Text display mode speed sending

Display speed constants collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(speed) ⇒ DisplaySpeed

Returns a new instance of DisplaySpeed.



30
31
32
# File 'lib/movingsign_api/commands/internal/display_speed.rb', line 30

def initialize(speed)
  @key = speed
end

Instance Attribute Details

#fasterSymbol (readonly)

Display speed :faster (protocol display speed ‘2’)

Returns:

  • (Symbol)

    :faster



20
# File 'lib/movingsign_api/commands/internal/display_speed.rb', line 20

display_speed :faster, '2'

#fastestSymbol (readonly)

Display speed :fastest (protocol display speed ‘1’)

Returns:

  • (Symbol)

    :fastest



19
# File 'lib/movingsign_api/commands/internal/display_speed.rb', line 19

display_speed :fastest, '1'

#keySymbol

Returns Display speed constant, one of #faster, #normal, #slow.

Returns:



28
29
30
# File 'lib/movingsign_api/commands/internal/display_speed.rb', line 28

def key
  @key
end

#normalSymbol (readonly)

Display speed :normal (protocol display speed ‘3’)

Returns:

  • (Symbol)

    :normal



21
# File 'lib/movingsign_api/commands/internal/display_speed.rb', line 21

display_speed :normal, '3'

#slowSymbol (readonly)

Display speed :slow (protocol display speed ‘4’)

Returns:

  • (Symbol)

    :slow



22
# File 'lib/movingsign_api/commands/internal/display_speed.rb', line 22

display_speed :slow, '4'

#slowerSymbol (readonly)

Display speed :slower (protocol display speed ‘5’)

Returns:

  • (Symbol)

    :slower



23
# File 'lib/movingsign_api/commands/internal/display_speed.rb', line 23

display_speed :slower, '5'

Class Method Details

.parse(input) ⇒ DisplaySpeed

Parses the supplied input into a MovingsignApi::DisplaySpeed instance if possible

Returns:

Raises:

  • InvalidInputError on invalid input



37
38
39
40
41
42
43
# File 'lib/movingsign_api/commands/internal/display_speed.rb', line 37

def self.parse(input)
  if key = parse_to_key(input)
    self.new key
  else
    raise InvalidInputError, "Display speed '#{input}' is invalid."
  end
end