class Object
Public Instance Methods
argument(*a, &b)
click to toggle source
# File lib/main/dsl.rb, line 5 def argument(*a, &b) (parameters << Parameter.create(:argument, self, *a, &b)).last end
Also aliased as: arg
can_has(ptype, *a, &b)
click to toggle source
# File lib/main/dsl.rb, line 37 def can_has(ptype, *a, &b) key = a.map{|s| s.to_s}.sort_by{|s| -s.size }.first can_has_hash.update key => [ptype, a, b] key end
default_options!()
click to toggle source
# File lib/main/dsl.rb, line 26 def default_options! option 'help', 'h' unless parameters.has_option?('help', 'h') end
environment(*a, &b)
click to toggle source
# File lib/main/dsl.rb, line 21 def environment(*a, &b) (parameters << Parameter.create(:environment, self, *a, &b)).last end
Also aliased as: env
has(key, *keys)
click to toggle source
# File lib/main/dsl.rb, line 43 def has(key, *keys) keys = [key, *keys].flatten.compact.map{|k| k.to_s} keys.map do |key| ptype, a, b = can_has_hash[key] abort "yo - can *not* has #{ key.inspect }!?" unless(ptype and a and b) send ptype, *a, &b key end end
keyword(*a, &b)
click to toggle source
# File lib/main/dsl.rb, line 16 def keyword(*a, &b) (parameters << Parameter.create(:keyword, self, *a, &b)).last end
Also aliased as: kw
mixin(name, *names, &block)
click to toggle source
# File lib/main/dsl.rb, line 53 def mixin(name, *names, &block) names = [name, *names].flatten.compact.map{|name| name.to_s} if block names.each do |name| mixin_table[name] = block end else names.each do |name| module_eval(&mixin_table[name]) end end end
mode(name, &block)
click to toggle source
# File lib/main/dsl.rb, line 30 def mode(name, &block) name = name.to_s modes[name] = block block.fattr(:name => name) block end
option(*a, &b)
click to toggle source
# File lib/main/dsl.rb, line 10 def option(*a, &b) (parameters << Parameter.create(:option, self, *a, &b)).last end
parameter(*a, &b)
click to toggle source
# File lib/main/dsl.rb, line 1 def parameter(*a, &b) (parameters << Parameter.create(:parameter, self, *a, &b)).last end
singleton_class(object = self, &block)
click to toggle source
# File lib/main/stdext.rb, line 2 def singleton_class(object = self, &block) singleton_class = class << object self end block ? singleton_class.module_eval(&block) : singleton_class end