Class: Orbacle::Scope
- Inherits:
-
Object
- Object
- Orbacle::Scope
- Defined in:
- lib/orbacle/scope.rb
Instance Attribute Summary collapse
-
#elems ⇒ Object
readonly
Returns the value of attribute elems.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #absolute_str ⇒ Object
- #decrease ⇒ Object
- #eigenclass? ⇒ Boolean
- #empty? ⇒ Boolean
- #increase_by_eigenclass ⇒ Object
- #increase_by_ref(const_ref) ⇒ Object
-
#initialize(elems, is_eigenclass) ⇒ Scope
constructor
A new instance of Scope.
- #to_const_name ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(elems, is_eigenclass) ⇒ Scope
Returns a new instance of Scope.
9 10 11 12 |
# File 'lib/orbacle/scope.rb', line 9 def initialize(elems, is_eigenclass) @elems = elems @is_eigenclass = is_eigenclass end |
Instance Attribute Details
#elems ⇒ Object (readonly)
Returns the value of attribute elems.
14 15 16 |
# File 'lib/orbacle/scope.rb', line 14 def elems @elems end |
Class Method Details
.empty ⇒ Object
5 6 7 |
# File 'lib/orbacle/scope.rb', line 5 def self.empty new([], false) end |
Instance Method Details
#==(other) ⇒ Object
51 52 53 |
# File 'lib/orbacle/scope.rb', line 51 def ==(other) @elems == other.elems && eigenclass? == other.eigenclass? end |
#absolute_str ⇒ Object
43 44 45 |
# File 'lib/orbacle/scope.rb', line 43 def absolute_str elems.join("::") end |
#decrease ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/orbacle/scope.rb', line 29 def decrease if eigenclass? Scope.new(elems, false) elsif elems.empty? raise else Scope.new(elems[0..-2], false) end end |
#eigenclass? ⇒ Boolean
47 48 49 |
# File 'lib/orbacle/scope.rb', line 47 def eigenclass? @is_eigenclass end |
#empty? ⇒ Boolean
39 40 41 |
# File 'lib/orbacle/scope.rb', line 39 def empty? elems.empty? end |
#increase_by_eigenclass ⇒ Object
24 25 26 27 |
# File 'lib/orbacle/scope.rb', line 24 def increase_by_eigenclass raise if eigenclass? Scope.new(elems, true) end |
#increase_by_ref(const_ref) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/orbacle/scope.rb', line 16 def increase_by_ref(const_ref) if const_ref.absolute? Scope.new(const_ref.const_name.elems, false) else Scope.new(elems + const_ref.const_name.elems, eigenclass?) end end |
#to_const_name ⇒ Object
59 60 61 |
# File 'lib/orbacle/scope.rb', line 59 def to_const_name ConstName.new(elems) end |
#to_s ⇒ Object
55 56 57 |
# File 'lib/orbacle/scope.rb', line 55 def to_s absolute_str end |