Class: XDry::PMethodImpl

Inherits:
Parser
  • Object
show all
Defined in:
lib/xdry/parsing/parsers.rb

Instance Attribute Summary

Attributes inherited from Parser

#scope

Instance Method Summary collapse

Methods inherited from Parser

#initialize, #to_s

Constructor Details

This class inherits a constructor from XDry::Parser

Instance Method Details

#parse_line!(line, eol_comments, indent) ⇒ Object



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/xdry/parsing/parsers.rb', line 134

def parse_line! line, eol_comments, indent
  case line
  when /^\}$/
    if indent == scope.start_node.indent
      yield NMethodEnd.new
    else
      yield NClosingBrace.new
    end
  when /\[\s*([\w.]+)\s+release\s*\]/
    expr = $1
    yield NReleaseCall.new(expr)
  when /\bself\s*\.\s*(\w+)\s*=\s*nil\s*[,;]/
    expr = $1
    yield NReleaseCall.new(expr)
  when /\b(\w+)\s*=\s*nil\s*[,;]/
    expr = $1
    yield NReleaseCall.new(expr)
  when /\[super\s/
    yield NSuperCall.new
  when /^return\b/
    yield NReturn.new
  end
end