Module: Uinit::Type::Context

Defined in:
lib/uinit/type/context.rb

Constant Summary collapse

Nil =
Const[nil].freeze
Boolean =
(Const[true] | Const[false]).freeze
Sym =
TypeOf[Symbol].freeze
Hsh =
TypeOf[Hash].freeze
Arr =
TypeOf[Array].freeze

Instance Method Summary collapse

Instance Method Details

#any_of(const, *consts) ⇒ Object



16
17
18
# File 'lib/uinit/type/context.rb', line 16

def any_of(const, *consts)
  consts.reduce(Const[const]) { |type, cst| type | Const[cst] }
end

#arrayObject



81
82
83
# File 'lib/uinit/type/context.rb', line 81

def array
  Arr
end

#array_of(type) ⇒ Object



12
13
14
# File 'lib/uinit/type/context.rb', line 12

def array_of(type)
  ArrayOf.new(type)
end

#booleanObject Also known as: bool



72
73
74
# File 'lib/uinit/type/context.rb', line 72

def boolean
  Boolean
end

#check(check = nil, &proc_check) ⇒ Object



20
21
22
# File 'lib/uinit/type/context.rb', line 20

def check(check = nil, &proc_check)
  Check.new(check || proc_check)
end

#const(const) ⇒ Object



24
25
26
# File 'lib/uinit/type/context.rb', line 24

def const(const)
  Const.new(const)
end

#floatObject



62
63
64
# File 'lib/uinit/type/context.rb', line 62

def float(**)
  Float.new(**)
end

#fn(arity = -1)) ⇒ Object



28
29
30
# File 'lib/uinit/type/context.rb', line 28

def fn(arity = -1)
  Fn.new(arity)
end

#hashObject



77
78
79
# File 'lib/uinit/type/context.rb', line 77

def hash
  Hsh
end

#implObject



36
37
38
# File 'lib/uinit/type/context.rb', line 36

def impl(*, **)
  Impl.new(*, **)
end

#integerObject Also known as: int



57
58
59
# File 'lib/uinit/type/context.rb', line 57

def integer(**)
  Integer.new(**)
end

#nilableObject Also known as: null, none



66
67
68
# File 'lib/uinit/type/context.rb', line 66

def nilable
  Nil
end

#schema(schema, strict: false) ⇒ Object



32
33
34
# File 'lib/uinit/type/context.rb', line 32

def schema(schema, strict: false)
  Schema.new(schema, strict:)
end

#set_of(type) ⇒ Object



40
41
42
# File 'lib/uinit/type/context.rb', line 40

def set_of(type)
  SetOf.new(type)
end

#stringObject Also known as: str



52
53
54
# File 'lib/uinit/type/context.rb', line 52

def string(**)
  String.new(**)
end

#symObject



85
86
87
# File 'lib/uinit/type/context.rb', line 85

def sym
  Sym
end

#type(type = BasicObject) ⇒ Object



44
45
46
# File 'lib/uinit/type/context.rb', line 44

def type(type = BasicObject)
  Type.new(type)
end

#type_of(type) ⇒ Object



48
49
50
# File 'lib/uinit/type/context.rb', line 48

def type_of(type)
  TypeOf.new(type)
end