Class: Decode::Language::Ruby::Reference
- Inherits:
-
Decode::Language::Reference
- Object
- Decode::Language::Reference
- Decode::Language::Ruby::Reference
- Defined in:
- lib/decode/language/ruby/reference.rb
Overview
An Ruby-specific reference which can be resolved to zero or more definitions.
Instance Attribute Summary
Attributes inherited from Decode::Language::Reference
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Decode::Language::Reference
#absolute?, #best, #initialize, #inspect, #lexical_path, #path, #priority, #relative?, #to_s
Constructor Details
This class inherits a constructor from Decode::Language::Reference
Class Method Details
.append_const(node, path = []) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/decode/language/ruby/reference.rb', line 19 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) ⇒ Object
13 14 15 16 17 |
# File 'lib/decode/language/ruby/reference.rb', line 13 def self.from_const(node, language) lexical_path = append_const(node) return self.new(node.location.expression.source, language, lexical_path) end |
Instance Method Details
#split(text) ⇒ Object
44 45 46 |
# File 'lib/decode/language/ruby/reference.rb', line 44 def split(text) text.scan(/(::|\.|#|:)?([^:.#]+)/) end |