Class: Bijou::Parse::Method

Inherits:
Def show all
Defined in:
lib/bijou/backend.rb

Overview

The class for the backend code generator that is used to render the %method block. It may contain its own %args block.

Instance Attribute Summary

Attributes inherited from Def

#name

Attributes inherited from Target

#args

Instance Method Summary collapse

Methods inherited from Def

#renderMethod

Methods inherited from Target

#render_args, #render_code, #render_code_, #render_expr, #render_line, #render_marker, #render_part

Constructor Details

#initialize(name) ⇒ Method

Returns a new instance of Method.



143
144
145
# File 'lib/bijou/backend.rb', line 143

def initialize(name)
  super(name)
end

Instance Method Details

#render_method(use_markers) ⇒ Object



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/bijou/backend.rb', line 147

def render_method(use_markers)
  result = ''

  if @name == 'fini'
    result << "  def #{@name}()\n"
  else
    result << "  def #{@name}(args)\n"
  end

  if @name == 'init'
    # For init, call super before derived code.
    result << "    super\n"
  end

  result << render_args(@name, use_markers)
  result << @output

  if @name == 'fini'
    # For fini, call super after derived code.
    result << "    super\n"
  end
  result << "  end\n"

  return result
end