Class: RubyBreaker::TypeDefs::Type
- Inherits:
-
Object
- Object
- RubyBreaker::TypeDefs::Type
- 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.
Direct Known Subclasses
AnyType, BlockType, DuckType, MethodListType, NilType, NominalType, OptionalType, OrType, VarLengthType
Instance Attribute Summary collapse
-
#ctx ⇒ Object
Speficies the context of the type.
Instance Method Summary collapse
-
#eql?(other) ⇒ Boolean
This method compares this object to another object syntactically.
-
#initialize(*args) ⇒ Type
constructor
A new instance of Type.
-
#subtype_of?(rhs) ⇒ Boolean
This is a shorthand for calling Typing.subtype_rel?.
-
#unparse(opts = {}) ⇒ Object
This method is a shorthand for calling TypeUnparser.unparse(t).
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
#ctx ⇒ Object
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.
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?
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 |