Class: RubyBreaker::TypeDefs::Type

Inherits:
Object
  • Object
show all
Defined in:
lib/rubybreaker/type/type.rb,
lib/rubybreaker/typing/subtyping.rb,
lib/rubybreaker/type/type_comparer.rb,
lib/rubybreaker/type/type_unparser.rb

Overview

– Reopening the class to allow subtyping more accessible.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Type

Returns a new instance of Type.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/rubybreaker/type/type.rb', line 47

def initialize(*args)
  case args[0]
  when Context
    @ctx = args[0]
  when Position
    @ctx = Context.new(args[0])
  when ObjectPosition
    @ctx = Context.new(args[0])
  else
    file = args[0]
    line = args[1]
    col = args[2]
    pos = Position.new(file,line,col)
    @ctx = Context.new(pos)
  end
end

Instance Attribute Details

#ctxObject

Speficies the context of the type.



45
46
47
# File 'lib/rubybreaker/type/type.rb', line 45

def ctx
  @ctx
end

Instance Method Details

#eql?(other) ⇒ Boolean

This method compares this object to another object syntactically.

Returns:

  • (Boolean)


139
140
141
# File 'lib/rubybreaker/type/type_comparer.rb', line 139

def eql?(other)
  TypeComparer.compare(self, other)
end

#subtype_of?(rhs) ⇒ Boolean

This is a shorthand for calling Typing.subtype_rel?

Returns:

  • (Boolean)


480
481
482
# File 'lib/rubybreaker/typing/subtyping.rb', line 480

def subtype_of?(rhs)
  return Typing.subtype_rel?(self,rhs)
end

#unparse(opts = {}) ⇒ Object

This method is a shorthand for calling TypeUnparser.unparse(t).



176
177
178
# File 'lib/rubybreaker/type/type_unparser.rb', line 176

def unparse(opts={})
  TypeUnparser.unparse(self, opts)
end