Module: LCDProc::MenuItem

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

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



32
33
34
# File 'lib/lcdproc/menu_item.rb', line 32

def id
  @id
end

#is_hiddenObject

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_typeObject (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_optionsObject

Returns the value of attribute lcdproc_options.



33
34
35
# File 'lib/lcdproc/menu_item.rb', line 33

def lcdproc_options
  @lcdproc_options
end

#lcdproc_typeObject (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

#nextObject (readonly)

Returns the value of attribute next.



32
33
34
# File 'lib/lcdproc/menu_item.rb', line 32

def next
  @next
end

#parent_menuObject (readonly)

Returns the value of attribute parent_menu.



32
33
34
# File 'lib/lcdproc/menu_item.rb', line 32

def parent_menu
  @parent_menu
end

#previousObject (readonly)

Returns the value of attribute previous.



32
33
34
# File 'lib/lcdproc/menu_item.rb', line 32

def previous
  @previous
end

#textObject

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, menu_item_class )
  @supported_types[type] = menu_item_class
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, options = {}, lcdproc_options = {} )
  if @supported_types.include? type
    menu_item = @supported_types[ type ].new( options, lcdproc_options )
    
    return menu_item
  else
    return nil
  end
  
end

.supported_typesObject

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_stringObject

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_as_string
  options_as_lcdproc = []
  @lcdproc_options.each{ |key,value| options_as_lcdproc << "-#{key} #{value}" }
  options_as_lcdproc.join(" ")
end