Class: Opsicle::Monitor::Panel

Inherits:
Object
  • Object
show all
Includes:
Translatable
Defined in:
lib/opsicle/monitor/panel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Translatable

#translate

Constructor Details

#initialize(height, width, top, left, structure = [], opts = {}) ⇒ Panel

Returns a new instance of Panel.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/opsicle/monitor/panel.rb', line 19

def initialize(height, width, top, left, structure = [], opts = {})
  @height = height
  @width  = width
  @top    = top
  @left   = left

  @dividers = {
    :left  => opts[:divider_l].to_s,
    :right => opts[:divider_r].to_s,
  }

  @divider_length = @dividers.values.map(&:length).inject(:+)

  @window = Curses::Window.new(@height, @width, @top, @left)

  @subpanels = build_subpanels(structure)

  @spies = {} # data sources for #structure
end

Instance Attribute Details

#divider_lengthObject (readonly)

Returns the value of attribute divider_length.



17
18
19
# File 'lib/opsicle/monitor/panel.rb', line 17

def divider_length
  @divider_length
end

#dividersObject (readonly)

Returns the value of attribute dividers.



16
17
18
# File 'lib/opsicle/monitor/panel.rb', line 16

def dividers
  @dividers
end

#heightObject (readonly)

Returns the value of attribute height.



12
13
14
# File 'lib/opsicle/monitor/panel.rb', line 12

def height
  @height
end

#leftObject (readonly)

Returns the value of attribute left.



15
16
17
# File 'lib/opsicle/monitor/panel.rb', line 15

def left
  @left
end

#topObject (readonly)

Returns the value of attribute top.



14
15
16
# File 'lib/opsicle/monitor/panel.rb', line 14

def top
  @top
end

#widthObject (readonly)

Returns the value of attribute width.



13
14
15
# File 'lib/opsicle/monitor/panel.rb', line 13

def width
  @width
end

Instance Method Details

#closeObject



39
40
41
# File 'lib/opsicle/monitor/panel.rb', line 39

def close
  @window.close
end

#refreshObject



43
44
45
46
47
# File 'lib/opsicle/monitor/panel.rb', line 43

def refresh
  @subpanels.each(&:refresh) # build changes

  @window.refresh # push changes to window
end

#refresh_spiesObject



49
50
51
# File 'lib/opsicle/monitor/panel.rb', line 49

def refresh_spies
  @spies.each { |_, s| s.refresh } # refresh data sources
end