class Decode::Language::Ruby::Reference
An Ruby-specific reference which can be resolved to zero or more definitions.
Public Class Methods
append_const(node, path = [])
click to toggle source
# File lib/decode/language/ruby/reference.rb, line 34 def self.append_const(node, path = []) parent, name = node.children if parent and parent.type != :cbase append_const(parent, path) end case node.type when :const if parent && parent.type != :cbase path << ['::', name] else path << [nil, name] end when :send path << ['#', name] when :cbase # Ignore. else raise ArgumentError, "Could not determine reference for #{node}!" end return path end
from_const(node, language)
click to toggle source
# File lib/decode/language/ruby/reference.rb, line 28 def self.from_const(node, language) lexical_path = append_const(node) return self.new(node.location.expression.source, language, lexical_path) end
Public Instance Methods
split(text)
click to toggle source
# File lib/decode/language/ruby/reference.rb, line 59 def split(text) text.scan(/(::|\.|#|:)?([^:.#]+)/) end