Sha256: 22b629fd4dda5d9ad332087f5b86e0cdfd86d7defb420309d6c428864a6c5cfe

Contents?: true

Size: 999 Bytes

Versions: 2

Compression:

Stored size: 999 Bytes

Contents

module Convoy
    module Formatter
        class Commands
            include Enumerable

            class << self
                def command_for(setup, context)
                    if context.empty?
                        GlobalCommand.new(setup)
                    else
                        Command.new(context.last, setup, context)
                    end
                end
            end

            attr_reader :setup, :context

            def initialize(setup, context)
                @setup   = setup
                @context = context
            end

            def each(&block)
                setup.canonical_command_names_for(context).each do |command_name|
                    command = Command.new(command_name, setup, context)
                    block.call(command)
                end
            end

            def count
                setup.canonical_command_names_for(context).size
            end

            alias_method :size, :count
        end
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
convoy-1.3.2 lib/convoy/formatter/commands.rb
convoy-1.2.0 lib/convoy/formatter/commands.rb