Class: Decode::Language::Ruby::Reference
- Inherits:
-
Object
- Object
- Decode::Language::Ruby::Reference
- Defined in:
- lib/decode/language/ruby.rb
Constant Summary collapse
- METHOD =
/\A(?<scope>.*?)?(?<kind>:|\.)(?<name>.+?)\z/
Instance Method Summary collapse
- #absolute? ⇒ Boolean
-
#initialize(value) ⇒ Reference
constructor
A new instance of Reference.
- #kind ⇒ Object
- #path ⇒ Object
Constructor Details
#initialize(value) ⇒ Reference
Returns a new instance of Reference.
43 44 45 46 47 48 |
# File 'lib/decode/language/ruby.rb', line 43 def initialize(value) @value = value @path = nil @kind = nil end |
Instance Method Details
#absolute? ⇒ Boolean
50 51 52 |
# File 'lib/decode/language/ruby.rb', line 50 def absolute? @value.start_with?('::') end |
#kind ⇒ Object
81 82 83 84 85 |
# File 'lib/decode/language/ruby.rb', line 81 def kind self.path return @kind end |
#path ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/decode/language/ruby.rb', line 56 def path if @path.nil? @path = @value.split(/::/) if last = @path.pop if match = last.match(METHOD) @kind = KIND[match[:kind]] if scope = match[:scope] @path << scope end @path << match[:name] else @path << last end end @path = @path.map(&:to_sym) @path.freeze end return @path end |