class RBS::Types::Optional
Attributes
location
[R]
loc?
type
[R]
t
Public Class Methods
(type: t, location: loc?) → void
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/types.rb, line 659 def initialize(type:, location:) @type = type @location = location end
Public Instance Methods
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/types.rb, line 664 def ==(other) other.is_a?(Optional) && other.type == type end
Also aliased as: eql?
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/types.rb, line 702 def each_type if block_given? yield type else enum_for :each_type end end
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/types.rb, line 674 def free_variables(set = Set.new) type.free_variables(set) end
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/types.rb, line 732 def has_classish_type? each_type.any? {|type| type.has_classish_type? } end
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/types.rb, line 728 def has_self_type? each_type.any? {|type| type.has_self_type? } end
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/types.rb, line 670 def hash self.class.hash ^ type.hash end
() { (t) → t } → Optional
() → Enumerator[t, Optional]
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/types.rb, line 717 def map_type(&block) if block Optional.new( type: yield(type), location: location ) else enum_for :map_type end end
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/types.rb, line 710 def map_type_name(&block) Optional.new( type: type.map_type_name(&block), location: location ) end
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/types.rb, line 682 def sub(s) return self if s.empty? self.class.new(type: type.sub(s), location: location) end
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/types.rb, line 678 def to_json(state = nil) { class: :optional, type: type, location: location }.to_json(state) end
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/types.rb, line 688 def to_s(level = 0) case t = type when RBS::Types::Literal case t.literal when Symbol return "#{type.to_s(1)} ?" end when RBS::Types::Proc return "(#{type.to_s(1)})?" end "#{type.to_s(1)}?" end
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/types.rb, line 736 def with_nonreturn_void? each_type.any? {|type| type.with_nonreturn_void? } # steep:ignore DeprecatedReference end