class RBS::Types::Optional
Attributes
Public Class Methods
Source
# File bundled-src/rbs-3.10.0/lib/rbs/types.rb, line 649 def initialize(type:, location:) @type = type @location = location end
Public Instance Methods
Source
# File bundled-src/rbs-3.10.0/lib/rbs/types.rb, line 654 def ==(other) other.is_a?(Optional) && other.type == type end
Also aliased as: eql?
Source
# File bundled-src/rbs-3.10.0/lib/rbs/types.rb, line 692 def each_type if block_given? yield type else enum_for :each_type end end
Source
# File bundled-src/rbs-3.10.0/lib/rbs/types.rb, line 664 def free_variables(set = Set.new) type.free_variables(set) end
Source
# File bundled-src/rbs-3.10.0/lib/rbs/types.rb, line 722 def has_classish_type? each_type.any? {|type| type.has_classish_type? } end
Source
# File bundled-src/rbs-3.10.0/lib/rbs/types.rb, line 718 def has_self_type? each_type.any? {|type| type.has_self_type? } end
Source
# File bundled-src/rbs-3.10.0/lib/rbs/types.rb, line 660 def hash self.class.hash ^ type.hash end
Source
# File bundled-src/rbs-3.10.0/lib/rbs/types.rb, line 707 def map_type(&block) if block Optional.new( type: yield(type), location: location ) else enum_for :map_type end end
Source
# File bundled-src/rbs-3.10.0/lib/rbs/types.rb, line 700 def map_type_name(&block) Optional.new( type: type.map_type_name(&block), location: location ) end
Source
# File bundled-src/rbs-3.10.0/lib/rbs/types.rb, line 672 def sub(s) return self if s.empty? self.class.new(type: type.sub(s), location: location) end
Source
# File bundled-src/rbs-3.10.0/lib/rbs/types.rb, line 668 def to_json(state = _ = nil) { class: :optional, type: type, location: location }.to_json(state) end
Source
# File bundled-src/rbs-3.10.0/lib/rbs/types.rb, line 678 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 bundled-src/rbs-3.10.0/lib/rbs/types.rb, line 726 def with_nonreturn_void? each_type.any? {|type| type.with_nonreturn_void? } end