Module: Excom::Plugins::Args::ClassMethods

Defined in:
lib/excom/plugins/args.rb

Instance Method Summary collapse

Instance Method Details

#arg_methodsObject



77
78
79
# File 'lib/excom/plugins/args.rb', line 77

def arg_methods
  const_get(:ArgMethods)
end

#args(*argz) ⇒ Object



81
82
83
84
85
86
87
# File 'lib/excom/plugins/args.rb', line 81

def args(*argz)
  args_list.concat(argz)

  argz.each_with_index do |name, i|
    arg_methods.send(:define_method, name){ @args[i] }
  end
end

#args_listObject



97
98
99
# File 'lib/excom/plugins/args.rb', line 97

def args_list
  @args_list ||= []
end

#inherited(command_class) ⇒ Object



70
71
72
73
74
75
# File 'lib/excom/plugins/args.rb', line 70

def inherited(command_class)
  command_class.const_set(:ArgMethods, Module.new)
  command_class.send(:include, command_class::ArgMethods)
  command_class.args_list.replace args_list.dup
  command_class.opts_list.replace opts_list.dup
end

#opts(*optz) ⇒ Object



89
90
91
92
93
94
95
# File 'lib/excom/plugins/args.rb', line 89

def opts(*optz)
  opts_list.concat(optz)

  optz.each do |name|
    arg_methods.send(:define_method, name){ @opts[name] }
  end
end

#opts_listObject



101
102
103
# File 'lib/excom/plugins/args.rb', line 101

def opts_list
  @opts_list ||= []
end