Class: Opsicle::Monitor::Subpanel
- Inherits:
-
Object
- Object
- Opsicle::Monitor::Subpanel
- Defined in:
- lib/opsicle/monitor/subpanel.rb
Instance Attribute Summary collapse
-
#content_width ⇒ Object
readonly
Returns the value of attribute content_width.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#dividers ⇒ Object
readonly
Returns the value of attribute dividers.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#left ⇒ Object
readonly
Returns the value of attribute left.
-
#top ⇒ Object
readonly
Returns the value of attribute top.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(window, height, width, top, left, opts = {}) ⇒ Subpanel
constructor
A new instance of Subpanel.
- #refresh ⇒ Object
Constructor Details
#initialize(window, height, width, top, left, opts = {}) ⇒ Subpanel
Returns a new instance of Subpanel.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/opsicle/monitor/subpanel.rb', line 13 def initialize(window, height, width, top, left, opts = {}) @window = window @height = height @width = width @top = top @left = left @data = { :left => opts[:data_l] || '', :right => opts[:data_r] || '', } @dividers = { :left => opts[:divider_l] || '', :right => opts[:divider_r] || '', } @content_width = @width - @dividers.values.map(&:length).inject(:+) end |
Instance Attribute Details
#content_width ⇒ Object (readonly)
Returns the value of attribute content_width.
11 12 13 |
# File 'lib/opsicle/monitor/subpanel.rb', line 11 def content_width @content_width end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
9 10 11 |
# File 'lib/opsicle/monitor/subpanel.rb', line 9 def data @data end |
#dividers ⇒ Object (readonly)
Returns the value of attribute dividers.
10 11 12 |
# File 'lib/opsicle/monitor/subpanel.rb', line 10 def dividers @dividers end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
5 6 7 |
# File 'lib/opsicle/monitor/subpanel.rb', line 5 def height @height end |
#left ⇒ Object (readonly)
Returns the value of attribute left.
8 9 10 |
# File 'lib/opsicle/monitor/subpanel.rb', line 8 def left @left end |
#top ⇒ Object (readonly)
Returns the value of attribute top.
7 8 9 |
# File 'lib/opsicle/monitor/subpanel.rb', line 7 def top @top end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
6 7 8 |
# File 'lib/opsicle/monitor/subpanel.rb', line 6 def width @width end |
Instance Method Details
#refresh ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/opsicle/monitor/subpanel.rb', line 33 def refresh new_current = content(@data[:left], @data[:right], @content_width) unless new_current == @data[:current] # don't redraw if hasn't changed @window.setpos(@top, @left) @window.addstr(@dividers[:left] + new_current + @dividers[:right]) end @data[:current] = new_current end |