Class: Torch::Argv::Flags
- Inherits:
-
Delegator
- Object
- Delegator
- Torch::Argv::Flags
show all
- Defined in:
- lib/torch/argv.rb
Instance Method Summary
collapse
Constructor Details
#initialize(argv) ⇒ Flags
Returns a new instance of Flags.
35
36
37
38
|
# File 'lib/torch/argv.rb', line 35
def initialize(argv)
@argv = argv
super
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_sym, *arguments, &block) ⇒ Object
65
66
67
68
69
70
71
|
# File 'lib/torch/argv.rb', line 65
def method_missing(method_sym, *arguments, &block)
if method_sym.to_s =~ /^_([a-zA-Z0-9_]+)\?$/
return include? $1
else
super
end
end
|
Instance Method Details
#__getobj__ ⇒ Object
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/torch/argv.rb', line 47
def __getobj__
@flags ||= @argv.select{|arg| arg[0,1] == '-'}.map do |arg|
if arg[0..1] == '--'
arg[2..-1]
else
arg[1..-1].split(//)
end
end.flatten
return @flags
end
|
#__setobj__(obj) ⇒ Object
44
45
|
# File 'lib/torch/argv.rb', line 44
def __setobj__(obj) end
|
#include?(flag) ⇒ Boolean
40
41
42
|
# File 'lib/torch/argv.rb', line 40
def include?(flag)
return super(flag.to_s)
end
|
#respond_to?(method_sym, include_private = false) ⇒ Boolean
58
59
60
61
62
63
64
|
# File 'lib/torch/argv.rb', line 58
def respond_to?(method_sym, include_private = false)
if method_sym.to_s =~ /^_([a-zA-Z0-9_]+)\?$/
return true
else
return super
end
end
|