Module: DjiMqttConnect::Mixins::CoverState

Defined in:
lib/dji_mqtt_connect/mixins/cover_state.rb

Instance Method Summary collapse

Instance Method Details

#humanized_cover_stateObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/dji_mqtt_connect/mixins/cover_state.rb', line 6

def humanized_cover_state
  return unless cover_state

  state_key = case cover_state
  when Types::COVER_STATE_CLOSED
    "Closed"
  when Types::COVER_STATE_OPEN
    "Open"
  when Types::COVER_STATE_HALF_OPEN
    "Half-open"
  when Types::COVER_STATE_ABNORMAL
    "Abnormal"
  end

  I18n.t(state_key.parameterize.underscore, scope: "dji_mqtt_connect.dock_cover_state", default: state_key)
end