Sha256: cc65c41ba002ea3da28de8c8e3ad604385b6df1b47bd8caeddffc3c9e9b90625

Contents?: true

Size: 804 Bytes

Versions: 1

Compression:

Stored size: 804 Bytes

Contents

module Slideparts
  class Command

    class << self

      def subclasses
        @subclasses ||= []
      end

      def inherited(base)
        subclasses << base
        super(base)
      end

      def slide_template
        File.expand_path("../slide_template", File.dirname(__FILE__))
      end

      def execute
        options = {}
        commands = OptionParser.new do |opt|
          subclasses.map(&:options).inject({}){|ret, option| ret.merge(option)}.each do |key, value|
            opt.on(*value) do |v|
              options[key] = v
            end
          end
        end.parse!

        subclasses.each do |subclass|
          if subclass.syntax.include? commands.first
            subclass.process(commands[1..-1], options)
          end
        end
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
slideparts-0.0.1 lib/slideparts/command.rb