Sha256: 31de520301eb4ebd7c8bb57321ffd5295b47c62769a3157d8286f56be6ea1ec4

Contents?: true

Size: 928 Bytes

Versions: 13

Compression:

Stored size: 928 Bytes

Contents

module Redcar
  class Menu
    class Item
      class Separator < Item
        def initialize
          super(nil, nil)
        end
      end
      
      attr_reader :text, :command
  
      # Create a new Item, with the given text to display in the menu, and
      # either:
      #   the Redcar::Command that is run when the item is selected.
      #   or a block to run when the item is selected
      def initialize(text, command=nil, &block)
        @text, @command = text, command
        if !command & block
          @command = block
        end
      end
      
      # Call this to signal that the menu item has been selected by the user.
      def selected(with_key=false)
        @command.new.run#(:with_key => with_key)
      end
      
      def merge(other)
        @command = other.command
      end
      
      def ==(other)
        text == other.text and command == other.command
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
redcar-0.3.8.4 plugins/application/lib/application/menu/item.rb
redcar-0.3.8.3 plugins/application/lib/application/menu/item.rb
redcar-0.3.8.2 plugins/application/lib/application/menu/item.rb
redcar-0.3.8.1 plugins/application/lib/application/menu/item.rb
redcar-0.3.8 plugins/application/lib/application/menu/item.rb
redcar-0.3.7.1 plugins/application/lib/application/menu/item.rb
redcar-0.3.7 plugins/application/lib/application/menu/item.rb
redcar-0.3.6 plugins/application/lib/application/menu/item.rb
redcar-0.3.5 plugins/application/lib/application/menu/item.rb
redcar-0.3.4.3 plugins/application/lib/application/menu/item.rb
redcar-0.3.4.2 plugins/application/lib/application/menu/item.rb
redcar-0.3.4.1 plugins/application/lib/application/menu/item.rb
redcar-0.3.4 plugins/application/lib/application/menu/item.rb