Sha256: 421a1551b851b6b2ea260df6876c0a46582b3035ca1d63b72a95aa33d6456c9f

Contents?: true

Size: 814 Bytes

Versions: 2

Compression:

Stored size: 814 Bytes

Contents

require 'movingsign_api/commands/command'

module MovingsignApi
  # Write control command base class, subclassed by actual implementations
  #
  # In subclasses, be sure to implement:
  # - {#subcommand_code}
  # - {#subcommand_payload_bytes}
  class WriteControlCommand < Command
    def command_code
      'W'
    end

    def subcommand_code
      raise MovingsignApi::NotImplementedError, "Needs to be implemented in subclass."
    end

    private

    def command_payload_bytes
      bytes = []

      bytes.concat string_to_ascii_bytes subcommand_code
      bytes.concat subcommand_payload_bytes

      bytes
    end

    # generates control sub-command specific bytes
    def subcommand_payload_bytes
      raise MovingsignApi::NotImplementedError, "Needs to be implemented in subclass."
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
movingsign_api-0.0.2 lib/movingsign_api/commands/write_control_command.rb
movingsign_api-0.0.1 lib/movingsign_api/commands/write_control_command.rb