Class: Orbacle::ConstName
- Inherits:
-
Object
- Object
- Orbacle::ConstName
- Defined in:
- lib/orbacle/const_name.rb
Instance Attribute Summary collapse
-
#elems ⇒ Object
readonly
Returns the value of attribute elems.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(elems) ⇒ ConstName
constructor
A new instance of ConstName.
- #name ⇒ Object
- #scope ⇒ Object
- #to_string ⇒ Object
Constructor Details
#initialize(elems) ⇒ ConstName
Returns a new instance of ConstName.
10 11 12 13 |
# File 'lib/orbacle/const_name.rb', line 10 def initialize(elems) @elems = elems raise ArgumentError if elems.empty? end |
Instance Attribute Details
#elems ⇒ Object (readonly)
Returns the value of attribute elems.
15 16 17 |
# File 'lib/orbacle/const_name.rb', line 15 def elems @elems end |
Class Method Details
.from_string(str) ⇒ Object
5 6 7 8 |
# File 'lib/orbacle/const_name.rb', line 5 def self.from_string(str) raise ArgumentError if str.start_with?("::") new(str.split("::")) end |
Instance Method Details
#==(other) ⇒ Object
17 18 19 |
# File 'lib/orbacle/const_name.rb', line 17 def ==(other) elems == other.elems end |
#name ⇒ Object
21 22 23 |
# File 'lib/orbacle/const_name.rb', line 21 def name elems.last end |
#scope ⇒ Object
29 30 31 |
# File 'lib/orbacle/const_name.rb', line 29 def scope Scope.new(elems[0..-2], false) end |
#to_string ⇒ Object
25 26 27 |
# File 'lib/orbacle/const_name.rb', line 25 def to_string elems.join("::") end |