class MovingsignApi::DisplayPause

Text display pause setting (in seconds, 0 - 9)

Attributes

seconds[RW]

@return [Integer] seconds

Public Class Methods

new(seconds) click to toggle source

@param seconds [Integer] Time to pause (in seconds) (0 - 9)

# File lib/movingsign_api/commands/internal/display_pause.rb, line 13
def initialize(seconds)
  @seconds = parse_seconds(seconds)
end

Public Instance Methods

to_bytes() click to toggle source
# File lib/movingsign_api/commands/internal/display_pause.rb, line 17
def to_bytes
  string_to_ascii_bytes self.seconds
end

Private Instance Methods

parse_seconds(input) click to toggle source
# File lib/movingsign_api/commands/internal/display_pause.rb, line 23
def parse_seconds(input)
  if input.kind_of?(String) && input.match(/\A[0-9]\z/)
    input.to_i
  elsif input.kind_of?(Fixnum) && input.between?(0, 9)
    input
  else
    raise "Pause time '#{input}' is invalid."
  end
end