Class: ESPHome::Cli::Entities::Form

Inherits:
ESPHome::Cli::Entity show all
Includes:
FormPrompt, MenuPrompt
Defined in:
lib/esphome/cli/entities/form.rb

Direct Known Subclasses

Date, DateTime, Number, Text, Time

Instance Attribute Summary

Attributes inherited from ESPHome::Cli::Entity

#cli, #index

Instance Method Summary collapse

Methods inherited from ESPHome::Cli::Entity

#move_left, #move_right, #print, #touch

Constructor Details

#initializeForm

Returns a new instance of Form.



77
78
79
80
81
# File 'lib/esphome/cli/entities/form.rb', line 77

def initialize(...)
  super

  @max_length = length_range&.end || 10
end

Instance Method Details

#activateObject



91
92
93
94
95
96
97
# File 'lib/esphome/cli/entities/form.rb', line 91

def activate
  value = prompt_form(form_title,
                      initial_value:,
                      suffix:,
                      field_width:)
  command(value) if value
end

#initial_valueObject



89
# File 'lib/esphome/cli/entities/form.rb', line 89

def initial_value = nil

#length_rangeObject



83
84
85
# File 'lib/esphome/cli/entities/form.rb', line 83

def length_range
  0..10
end

#suffixObject



87
# File 'lib/esphome/cli/entities/form.rb', line 87

def suffix = nil