Sha256: 90713288bd4090cd4fd5cc32bbf601bb964dd484fa98984e989694f58a93576f

Contents?: true

Size: 553 Bytes

Versions: 16

Compression:

Stored size: 553 Bytes

Contents

module Hiroshimarb

  # コマンドを実装する際の基底クラス
  class Command

    class << self

      def commands
        @commands ||= {}
      end

      def inherited(subclass)
        name = subclass.command_name
        commands[name] = subclass
      end

      def find(command_name)
        if command = commands[command_name.to_sym]
          command.new
        else
          nil
        end
      end

      def command_name
        name.split('::').last.downcase.to_sym
      end
    end

    def call(arg)
    end

  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
hiroshimarb-0.3.1 lib/hiroshimarb/command.rb
hiroshimarb-0.3.0 lib/hiroshimarb/command.rb
hiroshimarb-0.2.13 lib/hiroshimarb/command.rb
hiroshimarb-0.2.12 lib/hiroshimarb/command.rb
hiroshimarb-0.2.10 lib/hiroshimarb/command.rb
hiroshimarb-0.2.9 lib/hiroshimarb/command.rb
hiroshimarb-0.2.8 lib/hiroshimarb/command.rb
hiroshimarb-0.2.7 lib/hiroshimarb/command.rb
hiroshimarb-0.2.6 lib/hiroshimarb/command.rb
hiroshimarb-0.2.5 lib/hiroshimarb/command.rb
hiroshimarb-0.2.4 lib/hiroshimarb/command.rb
hiroshimarb-0.2.3 lib/hiroshimarb/command.rb
hiroshimarb-0.2.2 lib/hiroshimarb/command.rb
hiroshimarb-0.2.1 lib/hiroshimarb/command.rb
hiroshimarb-0.2.0 lib/hiroshimarb/command.rb
hiroshimarb-0.1.4 lib/hiroshimarb/command.rb