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?)
- #has_classish_type? ⇒ Boolean
- #has_self_type? ⇒ Boolean
- #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
- #with_nonreturn_void? ⇒ Boolean
Methods included from EmptyEachType
Methods included from NoSubst
Methods included from NoFreeVariables
Constructor Details
#initialize(name:, location:) ⇒ ClassSingleton
Returns a new instance of ClassSingleton.
204 205 206 207 |
# File 'lib/rbs/types.rb', line 204 def initialize(name:, location:) @name = name @location = location end |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
202 203 204 |
# File 'lib/rbs/types.rb', line 202 def location @location end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
201 202 203 |
# File 'lib/rbs/types.rb', line 201 def name @name end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
209 210 211 |
# File 'lib/rbs/types.rb', line 209 def ==(other) other.is_a?(ClassSingleton) && other.name == name end |
#has_classish_type? ⇒ Boolean
243 244 245 |
# File 'lib/rbs/types.rb', line 243 def has_classish_type? false end |
#has_self_type? ⇒ Boolean
239 240 241 |
# File 'lib/rbs/types.rb', line 239 def has_self_type? false end |
#hash ⇒ Object
215 216 217 |
# File 'lib/rbs/types.rb', line 215 def hash self.class.hash ^ name.hash end |
#map_type_name ⇒ Object
232 233 234 235 236 237 |
# File 'lib/rbs/types.rb', line 232 def map_type_name ClassSingleton.new( name: yield(name, location, self), location: location ) end |
#to_json(state = _ = nil) ⇒ Object
222 223 224 |
# File 'lib/rbs/types.rb', line 222 def to_json(state = _ = nil) { class: :class_singleton, name: name, location: location }.to_json(state) end |
#to_s(level = 0) ⇒ Object
226 227 228 |
# File 'lib/rbs/types.rb', line 226 def to_s(level = 0) "singleton(#{name})" end |
#with_nonreturn_void? ⇒ Boolean
247 248 249 |
# File 'lib/rbs/types.rb', line 247 def with_nonreturn_void? false end |