Class: RubyRich::AppShell::FramedView

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_rich/app_shell.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(component, title:, theme:, &focused) ⇒ FramedView

Returns a new instance of FramedView.



327
328
329
330
331
332
333
334
# File 'lib/ruby_rich/app_shell.rb', line 327

def initialize(component, title:, theme:, &focused)
  @component = component
  @title = title
  @theme = theme
  @focused = focused
  @width = 0
  @height = 0
end

Instance Attribute Details

#heightObject

Returns the value of attribute height.



325
326
327
# File 'lib/ruby_rich/app_shell.rb', line 325

def height
  @height
end

#widthObject

Returns the value of attribute width.



325
326
327
# File 'lib/ruby_rich/app_shell.rb', line 325

def width
  @width
end

Instance Method Details

#desired_heightObject



344
345
346
347
348
# File 'lib/ruby_rich/app_shell.rb', line 344

def desired_height
  return @height unless @component.respond_to?(:desired_height)

  @component.desired_height + 2
end

#renderObject



336
337
338
339
340
341
342
# File 'lib/ruby_rich/app_shell.rb', line 336

def render
  sync_component_dimensions
  panel = Panel.new(rendered_content, title: @title, border_style: @theme.panel_border(focused: @focused.call), title_align: :left)
  panel.width = @width
  panel.height = @height
  panel.render
end