Class: HandyToolbox::ToolMenuItem

Inherits:
Object
  • Object
show all
Defined in:
lib/handy_toolbox/tool_menu_item.rb

Constant Summary collapse

ICON =
'   '.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, tool) ⇒ ToolMenuItem

Returns a new instance of ToolMenuItem.



9
10
11
12
13
# File 'lib/handy_toolbox/tool_menu_item.rb', line 9

def initialize(parent, tool)
  @id = Ids.next
  @parent = parent
  @tool = tool
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/handy_toolbox/tool_menu_item.rb', line 7

def id
  @id
end

#parentObject (readonly)

Returns the value of attribute parent.



7
8
9
# File 'lib/handy_toolbox/tool_menu_item.rb', line 7

def parent
  @parent
end

#toolObject (readonly)

Returns the value of attribute tool.



7
8
9
# File 'lib/handy_toolbox/tool_menu_item.rb', line 7

def tool
  @tool
end

Instance Method Details

#iconObject



23
24
25
# File 'lib/handy_toolbox/tool_menu_item.rb', line 23

def icon
  ICON
end

#to_sObject



15
16
17
18
19
20
21
# File 'lib/handy_toolbox/tool_menu_item.rb', line 15

def to_s
  if @tool.desc.nil?
    @tool.name
  else
    [@tool.name, @tool.desc]
  end
end