Sha256: 2fe0557b14be9aa31000fa5ca30ea46ae672dbebf2bd3f5900b7044b51c598f3

Contents?: true

Size: 648 Bytes

Versions: 1

Compression:

Stored size: 648 Bytes

Contents

module MEACControl
  module Command
    class InvalidValue < Exception
    end

    class InvalidMode < Exception
    end

    class Generic
      attr_reader :command, :value

      def self.request
        new.freeze
      end

      def hash_for(mode)
        if mode == :set
          raise MEACControl::Command::InvalidValue if (value.nil? or value.empty?)
          {command.to_sym => value}
        elsif mode == :get
          {command.to_sym => '*'}
        else
          raise MEACControl::Command::InvalidMode
        end
      end

      def command_set?
        (value.nil? or value.empty?) ? false : true
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
meac_control-1.0.0 lib/meac_control/command/generic.rb