class RBS::Types::Variable
Attributes
location
[R]
loc?
Public Class Methods
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/types.rb, line 168 def self.build(v) case v when Symbol new(name: v, location: nil) when Array v.map {|x| new(name: x, location: nil) } end end
(?Symbol prefix) → Variable
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/types.rb, line 178 def self.fresh(v = :T) @@count = @@count + 1 new(name: :"#{v}@#{@@count}", location: nil) end
Returns fresh type variable with prefix (if given.)
Variable.fresh(:S) # => S@1 Variable.fresh(:S) # => S@2 Variable.fresh() # => T@3
(name: Symbol, location: loc?) → void
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/types.rb, line 139 def initialize(name:, location:) @name = name @location = location end
Public Instance Methods
(untyped other) → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/types.rb, line 144 def ==(other) other.is_a?(Variable) && other.name == name end
Also aliased as: eql?, eql?
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/types.rb, line 154 def free_variables(set = Set.new) set.tap do set << name end end
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/types.rb, line 193 def has_classish_type? false end
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/types.rb, line 189 def has_self_type? false end
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/types.rb, line 150 def hash self.class.hash ^ name.hash end
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/types.rb, line 164 def sub(s) s.apply(self) end
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/types.rb, line 160 def to_json(state = nil) { class: :variable, name: name, location: location }.to_json(state) end
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/types.rb, line 183 def to_s(level = 0) name.to_s end
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/types.rb, line 197 def with_nonreturn_void? false end