Class: ESPHome::Cli::Entity
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- ESPHome::Cli::Entity
- Defined in:
- lib/esphome/cli/entity.rb
Direct Known Subclasses
ESPHome::Cli::Entities::Button, ESPHome::Cli::Entities::Form, ESPHome::Cli::Entities::Menu, ESPHome::Cli::Entities::Subfields
Instance Attribute Summary collapse
-
#cli ⇒ Object
readonly
Returns the value of attribute cli.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
Instance Method Summary collapse
-
#initialize(cli, entity, index) ⇒ Entity
constructor
A new instance of Entity.
- #move_left ⇒ Object
- #move_right ⇒ Object
- #print(win, clear_line: true, active: false) ⇒ Object
- #touch ⇒ Object
Constructor Details
#initialize(cli, entity, index) ⇒ Entity
Returns a new instance of Entity.
10 11 12 13 14 15 16 |
# File 'lib/esphome/cli/entity.rb', line 10 def initialize(cli, entity, index) super(entity) @cli = cli @index = index touch end |
Instance Attribute Details
#cli ⇒ Object (readonly)
Returns the value of attribute cli.
8 9 10 |
# File 'lib/esphome/cli/entity.rb', line 8 def cli @cli end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
8 9 10 |
# File 'lib/esphome/cli/entity.rb', line 8 def index @index end |
Instance Method Details
#move_left ⇒ Object
19 |
# File 'lib/esphome/cli/entity.rb', line 19 def move_left = nil |
#move_right ⇒ Object
20 |
# File 'lib/esphome/cli/entity.rb', line 20 def move_right = nil |
#print(win, clear_line: true, active: false) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/esphome/cli/entity.rb', line 22 def print(win, clear_line: true, active: false) row = @index + Monitor::HEADER_ROWS return if row >= win.maxy win.setpos(row, 0) win.clrtoeol if clear_line safe_addstr(win, "#{name.ljust(cli.name_width)} : ") print_state(win, active:) return unless __getobj__.is_a?(ESPHome::Entity::HasState) = "[#{@last_update.strftime("%H:%M:%S.%L")}]" return if .length >= win.maxx pos = [win.cury, win.curx] win.setpos(row, win.maxx - .length) safe_addstr(win, ) win.setpos(*pos) if pos[1] < win.maxx rescue Curses::Error nil end |
#touch ⇒ Object
18 |
# File 'lib/esphome/cli/entity.rb', line 18 def touch = @last_update = Time.now |