Class: Lap::Method

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/lap/method.rb

Constant Summary

Constants included from Helpers

Helpers::CLASS_TO_LITERAL

Instance Method Summary collapse

Methods included from Helpers

#args, #get_comment, #with_comment

Constructor Details

#initialize(node, indent_level = 0) ⇒ Method

Returns a new instance of Method.



7
8
9
10
# File 'lib/lap/method.rb', line 7

def initialize(node, indent_level = 0)
  @node = node
  @indent_level = indent_level
end

Instance Method Details

#renderObject



12
13
14
15
16
17
18
19
20
# File 'lib/lap/method.rb', line 12

def render
  comment = get_comment(@node)
  result = <<~METHOD
    #{comment}def #{"self." unless @node.kind == :instance}#{@node.name}#{arguments}
      #{body}
    end
  METHOD
  result.indent(Lap::Config[:indent] * @indent_level)
end