In Files

  • rbs-1.0.4/lib/rbs/types.rb

Class/Module Index [+]

Quicksearch

RBS::Types::Variable

Attributes

location[R]
name[R]

Public Class Methods

build(v) click to toggle source
 
               # File rbs-1.0.4/lib/rbs/types.rb, line 136
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
            
fresh(v = :T) click to toggle source
 
               # File rbs-1.0.4/lib/rbs/types.rb, line 146
def self.fresh(v = :T)
  @@count = @@count + 1
  new(name: :"#{v}@#{@@count}", location: nil)
end
            
new(name:, location:) click to toggle source
 
               # File rbs-1.0.4/lib/rbs/types.rb, line 107
def initialize(name,, location))
  @name = name
  @location = location
end
            

Public Instance Methods

==(other) click to toggle source
 
               # File rbs-1.0.4/lib/rbs/types.rb, line 112
def ==(other)
  other.is_a?(Variable) && other.name == name
end
            
Also aliased as: eql?
eql?(other) click to toggle source
Alias for: ==
free_variables(set = Set.new) click to toggle source
 
               # File rbs-1.0.4/lib/rbs/types.rb, line 122
def free_variables(set = Set.new)
  set.tap do
    set << name
  end
end
            
hash() click to toggle source
 
               # File rbs-1.0.4/lib/rbs/types.rb, line 118
def hash
  self.class.hash ^ name.hash
end
            
sub(s) click to toggle source
 
               # File rbs-1.0.4/lib/rbs/types.rb, line 132
def sub(s)
  s.apply(self)
end
            
to_json(*a) click to toggle source
 
               # File rbs-1.0.4/lib/rbs/types.rb, line 128
def to_json(*a)
  { class: :variable, name: name, location: location }.to_json(*a)
end
            
to_s(level = 0) click to toggle source
 
               # File rbs-1.0.4/lib/rbs/types.rb, line 151
def to_s(level = 0)
  name.to_s
end