Class: RubyRich::AppShell::HeaderView
- Inherits:
-
Object
- Object
- RubyRich::AppShell::HeaderView
- Defined in:
- lib/ruby_rich/app_shell.rb
Instance Attribute Summary collapse
-
#height ⇒ Object
Returns the value of attribute height.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(shell) ⇒ HeaderView
constructor
A new instance of HeaderView.
- #render ⇒ Object
Constructor Details
#initialize(shell) ⇒ HeaderView
Returns a new instance of HeaderView.
247 248 249 250 251 |
# File 'lib/ruby_rich/app_shell.rb', line 247 def initialize(shell) @shell = shell @width = 0 @height = 1 end |
Instance Attribute Details
#height ⇒ Object
Returns the value of attribute height.
245 246 247 |
# File 'lib/ruby_rich/app_shell.rb', line 245 def height @height end |
#width ⇒ Object
Returns the value of attribute width.
245 246 247 |
# File 'lib/ruby_rich/app_shell.rb', line 245 def width @width end |
Instance Method Details
#render ⇒ Object
253 254 255 256 257 258 259 260 261 262 263 264 265 |
# File 'lib/ruby_rich/app_shell.rb', line 253 def render theme = @shell.theme left = "#{theme.style(@shell.instance_variable_get(:@title), :accent)} #{theme.style(@shell.instance_variable_get(:@subtitle), :muted)}" usage = @shell.token_usage usage_text = if usage && !usage.empty? total = usage[:total] || usage[:tokens] total ? "#{total} tok" : usage.map { |key, value| "#{key}=#{value}" }.join(" ") else "tokens --" end right = "#{theme.style(@shell.instance_variable_get(:@model), :status)} #{theme.style('● Live', :body)} #{theme.style(usage_text, :status)}" [join_edges(left, right, @width)] end |