Class: RBS::Types::Bases::Base
- Inherits:
-
Object
- Object
- RBS::Types::Bases::Base
- Includes:
- EmptyEachType, NoFreeVariables, NoSubst, NoTypeName
- Defined in:
- lib/rbs/types.rb
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(location:) ⇒ Base
constructor
A new instance of Base.
- #to_json(state = _ = nil) ⇒ Object
- #to_s(level = 0) ⇒ Object
Methods included from NoTypeName
Methods included from EmptyEachType
Methods included from NoSubst
Methods included from NoFreeVariables
Constructor Details
#initialize(location:) ⇒ Base
Returns a new instance of Base.
43 44 45 |
# File 'lib/rbs/types.rb', line 43 def initialize(location:) @location = location end |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
41 42 43 |
# File 'lib/rbs/types.rb', line 41 def location @location end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
47 48 49 |
# File 'lib/rbs/types.rb', line 47 def ==(other) other.is_a?(self.class) end |
#hash ⇒ Object
51 52 53 |
# File 'lib/rbs/types.rb', line 51 def hash self.class.hash end |
#to_json(state = _ = nil) ⇒ Object
62 63 64 65 |
# File 'lib/rbs/types.rb', line 62 def to_json(state = _ = nil) klass = to_s.to_sym { class: klass, location: location }.to_json(state) end |
#to_s(level = 0) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/rbs/types.rb', line 67 def to_s(level = 0) case self when Types::Bases::Bool 'bool' when Types::Bases::Void 'void' when Types::Bases::Any 'untyped' when Types::Bases::Nil 'nil' when Types::Bases::Top 'top' when Types::Bases::Bottom 'bot' when Types::Bases::Self 'self' when Types::Bases::Instance 'instance' when Types::Bases::Class 'class' else raise "Unexpected base type: #{inspect}" end end |