Class: LCDProc::MenuItems::Slider
- Inherits:
-
Object
- Object
- LCDProc::MenuItems::Slider
- Includes:
- LCDProc::MenuItem
- Defined in:
- lib/lcdproc/menu_items/slider.rb
Constant Summary collapse
- @@slider_item_count =
0
Instance Attribute Summary
Attributes included from LCDProc::MenuItem
#id, #is_hidden, #lcdproc_event_type, #lcdproc_options, #lcdproc_type, #next, #parent_menu, #previous, #text
Instance Method Summary collapse
-
#initialize(user_options = {}, lcdproc_options = {}) ⇒ Slider
constructor
Creates a new Slider MenuItem object.
Methods included from LCDProc::MenuItem
add_support, #lcdproc_options_as_string, new, supported_types
Constructor Details
#initialize(user_options = {}, lcdproc_options = {}) ⇒ Slider
Creates a new Slider MenuItem object.
The user_options
will accept a hash of the following MenuItem options.
-
:id
- The unique string that identifies this slider. Defaults to “SliderMenuItem_” + a sequence number.
The lcdproc_options
will accept a hash of the options to be passed to LCDd when creating or updating the slider.
-
:text
- The text to be displayed on the LCD for this slider. Defaults to the id. -
:mintext
- The text to be displayed at the far left (minimum) end of the slider. Defaults to “”. -
:maxtext
- The text to be displayed at the far left (maximum) end of the slider. Defaults to “”. -
:minvalue
- The minimum value that the slider should allow. Defaults to 0. -
:maxvalue
- The maximum value that the slider should allow. Defaults to 100. -
:value
- The initial starting value of the slider. Defaults to 0. -
:stepsize
- The number by which the value is increased with every press of the increment or decrement key. Defaults to 1. A value of 0 means that it can only be controled from within the client program.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/lcdproc/menu_items/slider.rb', line 52 def initialize( = {}, = {} ) @lcdproc_options = {} if [:id].nil? @id = "SliderMenuItem_#{@@slider_item_count}" else @id = [:id] end @lcdproc_type = "slider" @lcdproc_event_type = "(plus|minus)" @lcdproc_options[:text] = "#{@id}" @lcdproc_options[:mintext] = "" @lcdproc_options[:maxtext] = "" @lcdproc_options[:minvalue] = 0 @lcdproc_options[:maxvalue] = 100 @lcdproc_options[:value] = 0 @lcdproc_options[:stepsize] = 1 @lcdproc_options.update( ) [ :text, :mintext, :maxtext ].each { |s| @lcdproc_options[s].quotify! } @@slider_item_count += 1 end |