Class: MEACControl::Command::Generic

Inherits:
Object
  • Object
show all
Defined in:
lib/meac_control/command/generic.rb

Direct Known Subclasses

Drive, FanSpeed, InletTemp

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



10
11
12
# File 'lib/meac_control/command/generic.rb', line 10

def command
  @command
end

#valueObject (readonly)

Returns the value of attribute value.



10
11
12
# File 'lib/meac_control/command/generic.rb', line 10

def value
  @value
end

Class Method Details

.requestObject



12
13
14
# File 'lib/meac_control/command/generic.rb', line 12

def self.request
  new.freeze
end

Instance Method Details

#command_set?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/meac_control/command/generic.rb', line 27

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

#hash_for(mode) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/meac_control/command/generic.rb', line 16

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