class RETerm::Components::Histogram

CDK Histogram Widget

Attributes

value[RW]

Public Class Methods

new(args={}) click to toggle source

Initialize the Histogram component

@param [Hash] args label params @option args [String] :title title of Histogram @option args [Integer] :min min histogram value @option args [Integer] :max max histogram value

Calls superclass method RETerm::Component::new
# File lib/reterm/components/histogram.rb, line 27
def initialize(args={})
  super
  @title = args[:title] || ""
  @min   = args[:min]   || 0
  @max   = args[:max]   || 10
end

Public Instance Methods

requested_cols() click to toggle source
# File lib/reterm/components/histogram.rb, line 38
def requested_cols
  50
end
requested_rows() click to toggle source
# File lib/reterm/components/histogram.rb, line 34
def requested_rows
  4
end
value=(v) click to toggle source

Override setter

# File lib/reterm/components/histogram.rb, line 10
def value=(v)
  component.set(:PERCENT,        # view type
                CDK::CENTER,     # stats pos
                Ncurses::A_BOLD, # stats attr
                @min, @max, v,   # low/high/current
                ' '.ord | Ncurses::A_REVERSE, # fill ch
                true)            # box

  window.cdk_scr.refresh
end

Private Instance Methods

_component() click to toggle source
# File lib/reterm/components/histogram.rb, line 44
def _component
  CDK::HISTOGRAM.new(window.cdk_scr,
                     2, 1,            # x, y
                     1, -2,           # h, w
                     CDK::HORIZONTAL, # orient
                     @title,
                     true, false)     # box, shadow
end