Class: Method

Inherits:
Object show all
Defined in:
lib/robot-army/ruby2ruby_ext.rb

Instance Method Summary collapse

Instance Method Details

#argumentsObject



15
16
17
# File 'lib/robot-army/ruby2ruby_ext.rb', line 15

def arguments
  (to_ruby[/\A(def [^\s\(]+)(?:\(([^\)]*)\))?/, 2] || '').split(/\s*,\s*/)
end

#to_ruby_with_body_flag(only_body = false) ⇒ Object Also known as: to_ruby



19
20
21
22
23
24
25
26
27
# File 'lib/robot-army/ruby2ruby_ext.rb', line 19

def to_ruby_with_body_flag(only_body=false)
  ruby = self.to_ruby_without_body_flag
  if only_body
    ruby.sub!(/\A(def [^\s\(]+)(?:\(([^\)]*)\))?/, '')   # move args
    ruby.sub!(/end\Z/, '')                          # strip end
  end
  ruby.gsub!(/\s+$/, '')                            # trailing WS bugs me
  ruby
end