Module: LCDProc::MenuItem
- Included in:
- LCDProc::MenuItems::Action, LCDProc::MenuItems::Alpha, LCDProc::MenuItems::Checkbox, LCDProc::MenuItems::IP, LCDProc::MenuItems::Numeric, LCDProc::MenuItems::Ring, LCDProc::MenuItems::Slider, LCDProc::MenuItems::SubMenu
- Defined in:
- lib/lcdproc/menu_item.rb
Overview
MenuItem is a factory for creating new menu items and registering them with the client so that when the menu item’s event is processed, it can call the associated block.
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#is_hidden ⇒ Object
Returns the value of attribute is_hidden.
-
#lcdproc_event_type ⇒ Object
readonly
Returns the value of attribute lcdproc_event_type.
-
#lcdproc_options ⇒ Object
Returns the value of attribute lcdproc_options.
-
#lcdproc_type ⇒ Object
readonly
Returns the value of attribute lcdproc_type.
-
#next ⇒ Object
readonly
Returns the value of attribute next.
-
#parent_menu ⇒ Object
readonly
Returns the value of attribute parent_menu.
-
#previous ⇒ Object
readonly
Returns the value of attribute previous.
-
#text ⇒ Object
Returns the value of attribute text.
Class Method Summary collapse
-
.add_support(type, menu_item_class) ⇒ Object
Allows a particular type of menu item to inform the MenuItem module (which is a MenuItem factory) that it is able to support a particular type of menu item.
- .new(type = :string, options = {}, lcdproc_options = {}) ⇒ Object
-
.supported_types ⇒ Object
Returns an array of symbols listing the supported types of menu items.
Instance Method Summary collapse
-
#lcdproc_options_as_string ⇒ Object
Returns a string representation of the lcdproc_options that can be sent directly to LCDd.
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
32 33 34 |
# File 'lib/lcdproc/menu_item.rb', line 32 def id @id end |
#is_hidden ⇒ Object
Returns the value of attribute is_hidden.
32 33 34 |
# File 'lib/lcdproc/menu_item.rb', line 32 def is_hidden @is_hidden end |
#lcdproc_event_type ⇒ Object (readonly)
Returns the value of attribute lcdproc_event_type.
32 33 34 |
# File 'lib/lcdproc/menu_item.rb', line 32 def lcdproc_event_type @lcdproc_event_type end |
#lcdproc_options ⇒ Object
Returns the value of attribute lcdproc_options.
33 34 35 |
# File 'lib/lcdproc/menu_item.rb', line 33 def @lcdproc_options end |
#lcdproc_type ⇒ Object (readonly)
Returns the value of attribute lcdproc_type.
32 33 34 |
# File 'lib/lcdproc/menu_item.rb', line 32 def lcdproc_type @lcdproc_type end |
#next ⇒ Object (readonly)
Returns the value of attribute next.
32 33 34 |
# File 'lib/lcdproc/menu_item.rb', line 32 def next @next end |
#parent_menu ⇒ Object (readonly)
Returns the value of attribute parent_menu.
32 33 34 |
# File 'lib/lcdproc/menu_item.rb', line 32 def @parent_menu end |
#previous ⇒ Object (readonly)
Returns the value of attribute previous.
32 33 34 |
# File 'lib/lcdproc/menu_item.rb', line 32 def previous @previous end |
#text ⇒ Object
Returns the value of attribute text.
32 33 34 |
# File 'lib/lcdproc/menu_item.rb', line 32 def text @text end |
Class Method Details
.add_support(type, menu_item_class) ⇒ Object
Allows a particular type of menu item to inform the MenuItem module (which is a MenuItem factory) that it is able to support a particular type of menu item.
49 50 51 |
# File 'lib/lcdproc/menu_item.rb', line 49 def MenuItem.add_support( type, ) @supported_types[type] = end |
.new(type = :string, options = {}, lcdproc_options = {}) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/lcdproc/menu_item.rb', line 36 def MenuItem.new( type = :string, = {}, = {} ) if @supported_types.include? type = @supported_types[ type ].new( , ) return else return nil end end |
.supported_types ⇒ Object
Returns an array of symbols listing the supported types of menu items.
55 56 57 |
# File 'lib/lcdproc/menu_item.rb', line 55 def MenuItem.supported_types @supported_types.keys end |
Instance Method Details
#lcdproc_options_as_string ⇒ Object
Returns a string representation of the lcdproc_options that can be sent directly to LCDd.
86 87 88 89 90 |
# File 'lib/lcdproc/menu_item.rb', line 86 def = [] @lcdproc_options.each{ |key,value| << "-#{key} #{value}" } .join(" ") end |