Class: Dialekt::BasicTypeChecker
- Inherits:
-
Object
- Object
- Dialekt::BasicTypeChecker
- Defined in:
- lib/dialekt/basic_type_checker.rb
Overview
Type checker
Direct Known Subclasses
Instance Method Summary collapse
- #check!(type:, value:) ⇒ Object
- #format(type:) ⇒ Object
- #union_type(types:) ⇒ Object
- #valid?(type:, value:) ⇒ Boolean
Instance Method Details
#check!(type:, value:) ⇒ Object
17 18 19 20 21 |
# File 'lib/dialekt/basic_type_checker.rb', line 17 def check!(type:, value:) raise TypeError, "Object must be of type(s) #{type}" unless valid?(type: type, value: value) true end |
#format(type:) ⇒ Object
23 24 25 |
# File 'lib/dialekt/basic_type_checker.rb', line 23 def format(type:) PP.singleline_pp(type, StringIO.new).string end |
#union_type(types:) ⇒ Object
13 14 15 |
# File 'lib/dialekt/basic_type_checker.rb', line 13 def union_type(types:) raise NotImplementedError end |
#valid?(type:, value:) ⇒ Boolean
9 10 11 |
# File 'lib/dialekt/basic_type_checker.rb', line 9 def valid?(type:, value:) raise NotImplementedError end |