Class: RubyNodeReflector::RubyReflector::ScopeMethod
- Inherits:
-
Object
- Object
- RubyNodeReflector::RubyReflector::ScopeMethod
- Defined in:
- lib/ruby_reflector.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#_scopic(ref, node) ⇒ Object
this is complex because Ruby gloms several different kinds of variables into one “scope” token, and they don’t directly match their layout in the source code.
- #possible_comma(token) ⇒ Object
- #render_argument ⇒ Object
- #render_argument_list ⇒ Object
- #ulterior_comma(token) ⇒ Object
Instance Method Details
#_scopic(ref, node) ⇒ Object
this is complex because Ruby gloms several different
kinds of variables into one "scope" token, and they
don't directly match their layout in the source code
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/ruby_reflector.rb', line 235 def _scopic(ref, node) @ref = ref @node = node @expression = '' @previously = false @block_arg = false @splat_arg = false @previous_splat = false if @node[:tbl] @expression << '(' render_argument_list @expression << ')' end @expression << "\n" @expression << @ref.next_(@node) return @expression end |
#possible_comma(token) ⇒ Object
261 262 263 264 |
# File 'lib/ruby_reflector.rb', line 261 def possible_comma(token) @expression << ', ' if @index > 0 @expression << @ref._send(token) end |
#render_argument ⇒ Object
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
# File 'lib/ruby_reflector.rb', line 280 def render_argument @splat_arg = @block_arg = false if @rest and @rest.first == :lasgn and (@n == nil or @rest.last[:vid] == @n) ulterior_comma('*') @splat_arg = true end if @block and (ba = @block[1]) and ba.first == :block_arg and ba.last[:vid] == @n ulterior_comma('&') @block_arg = true end # ERGO Ruby 1.9 changes these rules!! if !@previous_splat or @block_arg if @opt and @opt.first == :block and # ERGO why a @block?? (lasgn = @opt.last.first).first == :lasgn and lasgn.last[:vid] == @n @previously = true possible_comma(@opt.last.first) else possible_comma(@n) @expression << ' = nil' if @previously and !@block_arg and !@splat_arg end @previous_splat ||= @splat_arg end end |
#render_argument_list ⇒ Object
266 267 268 269 270 271 272 273 274 275 276 277 278 |
# File 'lib/ruby_reflector.rb', line 266 def render_argument_list @nekst = @node[:next] @block = @nekst.last if @nekst && @nekst.first == :block @args = @block.first.last if @block && @block.first.first == :args @rest = @args[:rest] if @args @opt = @args[:opt] if @args @node[:tbl].each_with_index do |_n, _index| @n, @index = _n, _index render_argument break if @block_arg end end |
#ulterior_comma(token) ⇒ Object
255 256 257 258 259 |
# File 'lib/ruby_reflector.rb', line 255 def ulterior_comma(token) @expression << ', ' if @index > 0 @expression << token @index = 0 end |