Module: MethodAsExpression

Included in:
Method, UnboundMethod
Defined in:
lib/decompiler/method/as_expression.rb

Instance Method Summary collapse

Instance Method Details

#as_expressionObject

Return a single-line string representation of a method TODO: this method would be more aptly named “as_expression_string”.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/decompiler/method/as_expression.rb', line 9

def as_expression
  sig = self.signature
  if self.body.respond_to?(:body) then
    # YARV
    body_expression = self.body.body.as_expression
  else
    # pre-YARV
    body_expression = self.body.as_expression
  end
  if body_expression then
    return "def #{sig.name}(#{sig.param_list}); #{body_expression}; end"
  else
    return "def #{sig.name}(#{sig.param_list}); end"
  end
end