Class: RETerm::Components::HSlider

Inherits:
RETerm::Component show all
Includes:
RETerm::CDKComponent
Defined in:
lib/reterm/components/hslider.rb

Overview

Horizontal Slider, implemented using Slider CDK component

Constant Summary

Constants included from LogHelpers

LogHelpers::LOG_FILE

Instance Attribute Summary

Attributes inherited from RETerm::Component

#activatable, #activate_focus, #highlight_focus, #window

Instance Method Summary collapse

Methods included from RETerm::CDKComponent

#activatable?, #activate!, #bind_key, #cdk?, #colors=, #component, #deactivate!, #draw!, #early_exit?, #erase, #escape_hit?, #init?, #init_cdk, #normal_exit?, #strip_formatting, #title_attrib=, #value

Methods inherited from RETerm::Component

#activatable?, #activate!, #activate_focus?, #cdk?, #colored?, #colors=, #deactivate!, #deactivate?, #distance_from, #extra_padding, #finalize!, #highlight_focus?, #reactivate!, #resize, #sync!, #sync_getch

Methods included from KeyBindings

#bind_key, #invoke_key_bindings, #key_bindings, #key_bound?

Methods included from LogHelpers

#logger

Methods included from EventDispatcher

#dispatch, #handle

Constructor Details

#initialize(args = {}) ⇒ HSlider

Initialize the HSlider component

Parameters:

  • args (Hash) (defaults to: {})

    slider params

Options Hash (args):

  • :title (String)

    title of slider

  • :label (String)

    label of slider



12
13
14
15
16
17
18
19
# File 'lib/reterm/components/hslider.rb', line 12

def initialize(args={})
  super
  @title = args[:title] || " "
  @label = args[:label] || " "

  @increment     = 1
  @range         = [0, 100]
end

Instance Method Details

#requested_colsObject



21
22
23
# File 'lib/reterm/components/hslider.rb', line 21

def requested_cols
  [@title.size, @label.size].min + 30
end

#requested_rowsObject



25
26
27
# File 'lib/reterm/components/hslider.rb', line 25

def requested_rows
  4
end