Sha256: c8e404c2cfcb25afcb8c9390624498f21d6c4881dc5c89dabd96421abd278343
Contents?: true
Size: 575 Bytes
Versions: 1
Compression:
Stored size: 575 Bytes
Contents
class Ignoramos def initialize(args = []) command(args).execute end NilCommand = Struct.new(:args) do def execute puts 'command not supported' end end private def command(args) cmd = args.slice!(0) unless args.empty? Object.const_get(classify(cmd)).new(*args) rescue NameError NilCommand.new end def classify(command) snake_class = "#{command}_command" begin require "commands/#{snake_class}" rescue LoadError => e puts e.to_s end snake_class.split('_').collect(&:capitalize).join end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ignoramos-1.1.0 | lib/ignoramos.rb |