Class: LCDProc::MenuItems::Checkbox

Inherits:
Object
  • Object
show all
Includes:
LCDProc::MenuItem
Defined in:
lib/lcdproc/menu_items/checkbox.rb

Constant Summary collapse

@@checkbox_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

Methods included from LCDProc::MenuItem

add_support, #lcdproc_options_as_string, new, supported_types

Constructor Details

#initialize(user_options = {}, lcdproc_options = {}) ⇒ Checkbox

Creates a new Checkbox MenuItem object.

The user_options will accept a hash of the following MenuItem options.

  • :id - The unique string that identifies this checkbox. Defaults to “CheckboxMenuItem_” + a sequence number.

The lcdproc_options will accept a hash of the options to be passed to LCDd when creating or updating the checkbox.

  • :text - The text to be displayed on the LCD for this checkbox. Defaults to the id.

  • :value - The starting value. Valid options are :off, :on, and :gray (if :allow_grey is true). Defaults to :off.

  • :allow_grey - If true, the value may be set to :grey.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/lcdproc/menu_items/checkbox.rb', line 49

def initialize( user_options = {}, lcdproc_options = {} )
  @lcdproc_options = {}
  
  if user_options[:id].nil?
    @id = "CheckboxMenuItem_#{@@checkbox_item_count}"
  else
    @id = user_options[:id]
  end
  
  @lcdproc_type = "checkbox"
  @lcdproc_event_type = "update"
  
  @lcdproc_options[:text] = "#{@id}"
  
  @lcdproc_options[:value] = :off
  @lcdproc_options[:allow_gray] = false
  
  @lcdproc_options.update( lcdproc_options )
  
  @lcdproc_options[:text] = "\"#{@lcdproc_options[:text]}\""
  
  @@checkbox_item_count += 1
end