Class: YardTypes::Type
- Inherits:
-
Object
- Object
- YardTypes::Type
- Defined in:
- lib/yard_types/types.rb
Overview
The base class for all supported types.
Direct Known Subclasses
Instance Attribute Summary collapse
Class Method Summary collapse
- .for(name) ⇒ Object private
Instance Method Summary collapse
-
#check(obj) ⇒ Boolean
Whether the object is of this type.
-
#initialize(name) ⇒ Type
constructor
A new instance of Type.
-
#to_s ⇒ String
A YARD type string describing this type.
Constructor Details
#initialize(name) ⇒ Type
Returns a new instance of Type.
64 65 66 |
# File 'lib/yard_types/types.rb', line 64 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ String
47 48 49 |
# File 'lib/yard_types/types.rb', line 47 def name @name end |
Class Method Details
.for(name) ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/yard_types/types.rb', line 52 def self.for(name) case name when /^#/ DuckType.new(name) when *LiteralType.names LiteralType.new(name) else KindType.new(name) end end |
Instance Method Details
#check(obj) ⇒ Boolean
Returns whether the object is of this type.
76 77 78 |
# File 'lib/yard_types/types.rb', line 76 def check(obj) raise NotImplementedError end |
#to_s ⇒ String
Returns a YARD type string describing this type.
69 70 71 |
# File 'lib/yard_types/types.rb', line 69 def to_s name end |