Class: Decode::Symbol
- Inherits:
-
Object
- Object
- Decode::Symbol
- Defined in:
- lib/decode/symbol.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
-
#initialize(kind, name, parent: nil, language: parent.language) ⇒ Symbol
constructor
A new instance of Symbol.
- #inspect ⇒ Object
- #key ⇒ Object
- #lexical_path ⇒ Object
- #path ⇒ Object
- #qualified_name ⇒ Object
Constructor Details
#initialize(kind, name, parent: nil, language: parent.language) ⇒ Symbol
Returns a new instance of Symbol.
27 28 29 30 31 32 33 34 35 |
# File 'lib/decode/symbol.rb', line 27 def initialize(kind, name, parent: nil, language: parent.language) @kind = kind @name = name @parent = parent @language = language @path = nil @qualified_name = nil end |
Instance Attribute Details
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
45 46 47 |
# File 'lib/decode/symbol.rb', line 45 def kind @kind end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
48 49 50 |
# File 'lib/decode/symbol.rb', line 48 def language @language end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
46 47 48 |
# File 'lib/decode/symbol.rb', line 46 def name @name end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
47 48 49 |
# File 'lib/decode/symbol.rb', line 47 def parent @parent end |
Instance Method Details
#inspect ⇒ Object
41 42 43 |
# File 'lib/decode/symbol.rb', line 41 def inspect "\#<#{self.class} #{@kind} #{qualified_name}>" end |
#key ⇒ Object
37 38 39 |
# File 'lib/decode/symbol.rb', line 37 def key Key.new(@kind, @name) end |
#lexical_path ⇒ Object
64 65 66 |
# File 'lib/decode/symbol.rb', line 64 def lexical_path self.path.map(&:name) end |
#path ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/decode/symbol.rb', line 54 def path if @path @path elsif @parent @path = [*@parent.path, self.key] else @path = [self.key] end end |
#qualified_name ⇒ Object
50 51 52 |
# File 'lib/decode/symbol.rb', line 50 def qualified_name @qualified_name ||= @language.join(self.path).freeze end |