Class: LCDProc::MenuItems::Alpha

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

Constant Summary collapse

@@alpha_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 = {}) ⇒ Alpha

Creates a new Alpha MenuItem object.

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

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

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

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

  • :value - The string that you wish to be able to modify. Defaults to “AString”.

  • :password_char - If you wish that the text entered be a password, you may set this char to appear instead of the actual letters. Defaults to “” (off).

  • :minlength - The minimum allowed length of the string. Defaults to 0.

  • :maxlength - The maximum allowed length of the string. Defaults to 10.

  • :allow_caps - Whether or not the string is allowed to have capital letters. Defaults to true.

  • :allow_noncaps - ??? Not quite sure about this one, I believe it is whether or not you may have lower case letters. Defaults to false (this is the puzzling part).

  • :allow_numbers - Whether or not the string is allowed to have numbers. Defaults to false.

  • :allow_extras - A string containing any other characters that you wish to be allowed. Defaults to “”.



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
79
80
# File 'lib/lcdproc/menu_items/alpha.rb', line 54

def initialize( user_options = {}, lcdproc_options = {} )
  @lcdproc_options = {}
  
  if user_options[:id].nil?
    @id = "AlphaMenuItem_#{@@alpha_item_count}"
  else
    @id = user_options[:id]
  end
  
  @lcdproc_type = "alpha"
  @lcdproc_event_type = "update"
  
  @lcdproc_options[:text] = "#{@id}"
  @lcdproc_options[:value] = "AString"
  @lcdproc_options[:password_char] = ""
  @lcdproc_options[:minlength] = 0
  @lcdproc_options[:maxlength] = 10
  @lcdproc_options[:allow_caps] = true
  @lcdproc_options[:allow_noncaps] = false
  @lcdproc_options[:allow_numbers] = false
  
  @lcdproc_options.update( lcdproc_options )
  
  [ :text, :value, :password_char ].each { |s| @lcdproc_options[s].quotify! }
  
  @@alpha_item_count += 1
end