Module: Arguments
- Defined in:
- lib/arguments.rb,
lib/arguments/vm.rb,
lib/arguments/mri.rb
Defined Under Namespace
Classes: PermissiveRubyParser
Constant Summary
collapse
- VERSION =
'0.6'
Class Method Summary
collapse
Class Method Details
.ast_for_method(klass, method) ⇒ Object
15
16
17
18
19
20
|
# File 'lib/arguments/vm.rb', line 15
def self.ast_for_method klass, method
source, line = klass.instance_method(method).source_location
str = IO.readlines( source )[ (line-1)..-1 ].join
ast = PermissiveRubyParser.new.parse( str )
ast.assoc( :defn ) or ast
end
|
.names(klass, method) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/arguments.rb', line 12
def self.names klass, method
args = ast_for_method(klass, method).assoc(:args)
args = args[1..-1]
return [] if args.empty? or args.last.is_a?(Symbol)
vals = args.pop[1..-1]
args.collect do |arg|
if val = vals.find{ |v| v[1] == arg }
[arg, Ruby2Ruby.new.process(val.last)]
else
[arg]
end
end
end
|