Class: MovingsignApi::AlignMode

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

Overview

Align mode for a sign.

Valid values are:

  • :left or ‘1’

  • :center or ‘2’

  • :right or ‘3

Align Mode Constants collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ AlignMode

Returns a new instance of AlignMode.

Parameters:

  • key (Symbol)

    one of the valid alignment keys



36
37
38
# File 'lib/movingsign_api/commands/internal/align_mode.rb', line 36

def initialize(key)
  @key = key
end

Instance Attribute Details

#centerSymbol (readonly)

Align mode :center (protocol align mode ‘2’)

Returns:

  • (Symbol)

    :center



32
# File 'lib/movingsign_api/commands/internal/align_mode.rb', line 32

align_mode :center, '2'

#keySymbol

Returns align mode (one of #left, #right, #center).

Returns:



14
15
16
# File 'lib/movingsign_api/commands/internal/align_mode.rb', line 14

def key
  @key
end

#leftSymbol (readonly)

Align mode :left (protocol align mode ‘1’)

Returns:

  • (Symbol)

    :left



30
# File 'lib/movingsign_api/commands/internal/align_mode.rb', line 30

align_mode :left, '1'

#rightSymbol (readonly)

Align mode :right (protocol align mode ‘3’)

Returns:

  • (Symbol)

    :right



31
# File 'lib/movingsign_api/commands/internal/align_mode.rb', line 31

align_mode :right, '3'

Class Method Details

.parse(input) ⇒ AlignMode

Parses an symbol or string into a valid MovingsignApi::AlignMode instance

Returns:



42
43
44
45
46
47
48
# File 'lib/movingsign_api/commands/internal/align_mode.rb', line 42

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