Class: Contraction::Type
- Inherits:
-
Object
- Object
- Contraction::Type
- Defined in:
- lib/parser/type_parser.rb
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Instance Method Summary collapse
- #check(thing) ⇒ Object
-
#initialize(klass) ⇒ Type
constructor
A new instance of Type.
- #works_as_a?(thing) ⇒ Boolean
Constructor Details
#initialize(klass) ⇒ Type
Returns a new instance of Type.
42 43 44 |
# File 'lib/parser/type_parser.rb', line 42 def initialize(klass) @klass = klass end |
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
41 42 43 |
# File 'lib/parser/type_parser.rb', line 41 def klass @klass end |
Instance Method Details
#check(thing) ⇒ Object
50 51 52 |
# File 'lib/parser/type_parser.rb', line 50 def check(thing) works_as_a?(thing) end |
#works_as_a?(thing) ⇒ Boolean
46 47 48 |
# File 'lib/parser/type_parser.rb', line 46 def works_as_a?(thing) thing == klass || thing.is_a?(klass) end |