Class: RBS::Types::Optional
- Inherits:
-
Object
- Object
- RBS::Types::Optional
- Defined in:
- lib/rbs/types.rb
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #each_type ⇒ Object
- #free_variables(set = Set.new) ⇒ Object
- #hash ⇒ Object
-
#initialize(type:, location:) ⇒ Optional
constructor
A new instance of Optional.
- #sub(s) ⇒ Object
- #to_json(*a) ⇒ Object
- #to_s(level = 0) ⇒ Object
Constructor Details
#initialize(type:, location:) ⇒ Optional
Returns a new instance of Optional.
410 411 412 413 |
# File 'lib/rbs/types.rb', line 410 def initialize(type:, location:) @type = type @location = location end |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
408 409 410 |
# File 'lib/rbs/types.rb', line 408 def location @location end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
407 408 409 |
# File 'lib/rbs/types.rb', line 407 def type @type end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
415 416 417 |
# File 'lib/rbs/types.rb', line 415 def ==(other) other.is_a?(Optional) && other.type == type end |
#each_type ⇒ Object
445 446 447 448 449 450 451 |
# File 'lib/rbs/types.rb', line 445 def each_type if block_given? yield type else enum_for :each_type end end |
#free_variables(set = Set.new) ⇒ Object
425 426 427 |
# File 'lib/rbs/types.rb', line 425 def free_variables(set = Set.new) type.free_variables(set) end |
#hash ⇒ Object
421 422 423 |
# File 'lib/rbs/types.rb', line 421 def hash self.class.hash ^ type.hash end |
#sub(s) ⇒ Object
433 434 435 |
# File 'lib/rbs/types.rb', line 433 def sub(s) self.class.new(type: type.sub(s), location: location) end |
#to_json(*a) ⇒ Object
429 430 431 |
# File 'lib/rbs/types.rb', line 429 def to_json(*a) { class: :optional, type: type, location: location }.to_json(*a) end |