Class: Dialekt::BasicTypeChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/dialekt/basic_type_checker.rb

Overview

Type checker

Direct Known Subclasses

RubyTypeChecker

Instance Method Summary collapse

Instance Method Details

#check!(type:, value:) ⇒ Object

Raises:

  • (TypeError)


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

Raises:

  • (NotImplementedError)


13
14
15
# File 'lib/dialekt/basic_type_checker.rb', line 13

def union_type(types:)
  raise NotImplementedError
end

#valid?(type:, value:) ⇒ Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


9
10
11
# File 'lib/dialekt/basic_type_checker.rb', line 9

def valid?(type:, value:)
  raise NotImplementedError
end