Class: RBS::Types::ClassSingleton
- Inherits:
-
Object
- Object
- RBS::Types::ClassSingleton
- Includes:
- EmptyEachType, NoFreeVariables, NoSubst
- Defined in:
- lib/rbs/types.rb
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(name:, location:) ⇒ ClassSingleton
constructor
A new instance of ClassSingleton.
- #map_type_name ⇒ Object
- #to_json(state = _ = nil) ⇒ Object
- #to_s(level = 0) ⇒ Object
Methods included from EmptyEachType
Methods included from NoSubst
Methods included from NoFreeVariables
Constructor Details
#initialize(name:, location:) ⇒ ClassSingleton
Returns a new instance of ClassSingleton.
161 162 163 164 |
# File 'lib/rbs/types.rb', line 161 def initialize(name:, location:) @name = name @location = location end |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
159 160 161 |
# File 'lib/rbs/types.rb', line 159 def location @location end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
158 159 160 |
# File 'lib/rbs/types.rb', line 158 def name @name end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
166 167 168 |
# File 'lib/rbs/types.rb', line 166 def ==(other) other.is_a?(ClassSingleton) && other.name == name end |
#hash ⇒ Object
172 173 174 |
# File 'lib/rbs/types.rb', line 172 def hash self.class.hash ^ name.hash end |
#map_type_name ⇒ Object
189 190 191 192 193 194 |
# File 'lib/rbs/types.rb', line 189 def map_type_name ClassSingleton.new( name: yield(name, location, self), location: location ) end |
#to_json(state = _ = nil) ⇒ Object
179 180 181 |
# File 'lib/rbs/types.rb', line 179 def to_json(state = _ = nil) { class: :class_singleton, name: name, location: location }.to_json(state) end |
#to_s(level = 0) ⇒ Object
183 184 185 |
# File 'lib/rbs/types.rb', line 183 def to_s(level = 0) "singleton(#{name})" end |