Class: Main::Program::ClassMethods::Factory
- Defined in:
- lib/main/program/class_methods.rb
Instance Method Summary collapse
- #build(*args, &block) ⇒ Object
-
#initialize(&block) ⇒ Factory
constructor
A new instance of Factory.
- #to_proc ⇒ Object
Constructor Details
#initialize(&block) ⇒ Factory
Returns a new instance of Factory.
44 45 46 |
# File 'lib/main/program/class_methods.rb', line 44 def initialize(&block) @block = block || lambda{} end |
Instance Method Details
#build(*args, &block) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/main/program/class_methods.rb', line 52 def build(*args, &block) argv = (args.shift || ARGV).map{|arg| arg.dup} env = (args.shift || ENV).to_hash.dup opts = (args.shift || {}).to_hash.dup factory = self program = Class.new(Program) program.factory = factory program.argv = argv program.env = env program.opts = opts program.module_eval(&factory) program.module_eval do dynamically_extend_via_commandline_modes! program. define_method(:run, &block) if block wrap_run! end program end |
#to_proc ⇒ Object
48 49 50 |
# File 'lib/main/program/class_methods.rb', line 48 def to_proc @block end |