Class: Optopus::DefinerContext

Inherits:
Object
  • Object
show all
Defined in:
lib/optopus.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ DefinerContext

Returns a new instance of DefinerContext.



20
21
22
# File 'lib/optopus.rb', line 20

def initialize(opts)
  @opts = opts
end

Class Method Details

.evaluate(opts, &block) ⇒ Object



16
17
18
# File 'lib/optopus.rb', line 16

def self.evaluate(opts, &block)
  self.new(opts).instance_eval(&block)
end

Instance Method Details

#after(&block) ⇒ Object



51
52
53
# File 'lib/optopus.rb', line 51

def after(&block)
  @opts.add_after(block)
end

#banner=(v) ⇒ Object



24
# File 'lib/optopus.rb', line 24

def banner=(v)         ; @opts.banner = v         ; end

#before(&block) ⇒ Object



47
48
49
# File 'lib/optopus.rb', line 47

def before(&block)
  @opts.add_before(block)
end

#config_file(args_hd, *args_tl) ⇒ Object



41
42
43
44
45
# File 'lib/optopus.rb', line 41

def config_file(args_hd, *args_tl)
  @desc ||= 'reading config file'
  @opts.add_file([args_hd] + args_tl, @desc)
  @desc = nil
end

#default_argv=(v) ⇒ Object



28
# File 'lib/optopus.rb', line 28

def default_argv=(v)   ; @opts.default_argv = v   ; end

#desc(str) ⇒ Object



32
33
34
# File 'lib/optopus.rb', line 32

def desc(str)
  @desc = str
end

#error(&block) ⇒ Object



55
56
57
# File 'lib/optopus.rb', line 55

def error(&block)
  @opts.add_error(block)
end

#option(name, args_hd, *args_tl, &block) ⇒ Object



36
37
38
39
# File 'lib/optopus.rb', line 36

def option(name, args_hd, *args_tl, &block)
  @opts.add(name, [args_hd] + args_tl, @desc, block)
  @desc = nil
end

#program_name=(v) ⇒ Object



25
# File 'lib/optopus.rb', line 25

def program_name=(v)   ; @opts.program_name = v   ; end

#release=(v) ⇒ Object



30
# File 'lib/optopus.rb', line 30

def release=(v)        ; @opts.release = v        ; end

#summary_indent=(v) ⇒ Object



27
# File 'lib/optopus.rb', line 27

def summary_indent=(v) ; @opts.summary_indent = v ; end

#summary_width=(v) ⇒ Object



26
# File 'lib/optopus.rb', line 26

def summary_width=(v)  ; @opts.psummary_width = v ; end

#version=(v) ⇒ Object



29
# File 'lib/optopus.rb', line 29

def version=(v)        ; @opts.version = v        ; end