Class: YardTypes::Type Abstract
- Inherits:
-
Object
- Object
- YardTypes::Type
- Defined in:
- lib/yard_types/types.rb
Overview
This class is abstract.
The base class for all supported types.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ String
The YARD string naming this type.
Class Method Summary collapse
- .for(name) ⇒ Object private
Instance Method Summary collapse
-
#check(obj) ⇒ Boolean
Whether the object is of this type.
-
#description ⇒ String
An English phrase describing 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.
77 78 79 |
# File 'lib/yard_types/types.rb', line 77 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ String
Returns the YARD string naming this type.
60 61 62 |
# File 'lib/yard_types/types.rb', line 60 def name @name end |
Class Method Details
.for(name) ⇒ Object
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/yard_types/types.rb', line 65 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.
94 95 96 |
# File 'lib/yard_types/types.rb', line 94 def check(obj) raise NotImplementedError end |
#description ⇒ String
Returns an English phrase describing this type.
87 88 89 |
# File 'lib/yard_types/types.rb', line 87 def description raise NotImplementedError end |
#to_s ⇒ String
Returns a YARD type string describing this type.
82 83 84 |
# File 'lib/yard_types/types.rb', line 82 def to_s name end |