Class: Orbacle::ConstRef
- Inherits:
-
Object
- Object
- Orbacle::ConstRef
- Defined in:
- lib/orbacle/const_ref.rb
Instance Attribute Summary collapse
-
#const_name ⇒ Object
readonly
Returns the value of attribute const_name.
-
#is_absolute ⇒ Object
readonly
Returns the value of attribute is_absolute.
-
#nesting ⇒ Object
readonly
Returns the value of attribute nesting.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #absolute? ⇒ Boolean
-
#initialize(const_name, is_absolute, nesting) ⇒ ConstRef
constructor
A new instance of ConstRef.
- #name ⇒ Object
- #relative_name ⇒ Object
Constructor Details
#initialize(const_name, is_absolute, nesting) ⇒ ConstRef
Returns a new instance of ConstRef.
19 20 21 22 23 |
# File 'lib/orbacle/const_ref.rb', line 19 def initialize(const_name, is_absolute, nesting) @const_name = const_name @is_absolute = is_absolute @nesting = nesting end |
Instance Attribute Details
#const_name ⇒ Object (readonly)
Returns the value of attribute const_name.
25 26 27 |
# File 'lib/orbacle/const_ref.rb', line 25 def const_name @const_name end |
#is_absolute ⇒ Object (readonly)
Returns the value of attribute is_absolute.
25 26 27 |
# File 'lib/orbacle/const_ref.rb', line 25 def is_absolute @is_absolute end |
#nesting ⇒ Object (readonly)
Returns the value of attribute nesting.
25 26 27 |
# File 'lib/orbacle/const_ref.rb', line 25 def nesting @nesting end |
Class Method Details
.from_ast(ast, nesting) ⇒ Object
5 6 7 8 |
# File 'lib/orbacle/const_ref.rb', line 5 def self.from_ast(ast, nesting) full_name = AstUtils.const_to_string(ast) from_full_name(full_name, nesting) end |
.from_full_name(full_name, nesting) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/orbacle/const_ref.rb', line 10 def self.from_full_name(full_name, nesting) if full_name.start_with?("::") name = full_name[2..-1] new(ConstName.from_string(name), true, nesting) else new(ConstName.from_string(full_name), false, nesting) end end |
Instance Method Details
#==(other) ⇒ Object
39 40 41 42 43 |
# File 'lib/orbacle/const_ref.rb', line 39 def ==(other) const_name == other.const_name && is_absolute == other.is_absolute && nesting == other.nesting end |
#absolute? ⇒ Boolean
27 28 29 |
# File 'lib/orbacle/const_ref.rb', line 27 def absolute? @is_absolute end |
#name ⇒ Object
35 36 37 |
# File 'lib/orbacle/const_ref.rb', line 35 def name const_name.name end |
#relative_name ⇒ Object
31 32 33 |
# File 'lib/orbacle/const_ref.rb', line 31 def relative_name const_name.to_string end |