Class: ESPHome::Cli::Entities::Time
- Inherits:
-
Form
- Object
- SimpleDelegator
- ESPHome::Cli::Entity
- Form
- ESPHome::Cli::Entities::Time
- Defined in:
- lib/esphome/cli/entities/time.rb
Instance Attribute Summary
Attributes inherited from ESPHome::Cli::Entity
Instance Method Summary collapse
Methods inherited from Form
#activate, #initial_value, #initialize, #suffix
Methods inherited from ESPHome::Cli::Entity
#initialize, #move_left, #move_right, #print, #touch
Constructor Details
This class inherits a constructor from ESPHome::Cli::Entities::Form
Instance Method Details
#command(value) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/esphome/cli/entities/time.rb', line 13 def command(value) if defined?(ActiveSupport::Duration) begin value = ActiveSupport::Duration.parse(value) rescue ArgumentError # ignore; try to parse another way end end begin if value.is_a?(String) value = value.split(":").map { |v| Integer(v) } raise ArgumentError if value.length > 3 value.unshift(0) while value.length < 3 end rescue ArgumentError cli.error("Invalid time: #{value}") return end cli.info("Setting #{object_id_} to #{value.iso8601}") super end |
#length_range ⇒ Object
9 10 11 |
# File 'lib/esphome/cli/entities/time.rb', line 9 def length_range 25..25 end |