Module: Uinit::Type::Context

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

Constant Summary collapse

Nil =
Const[nil].freeze
Boolean =
(Const[true] | Const[false]).freeze
Str =
Instance[String].freeze
Int =
Instance[Integer].freeze
Float =
Instance[Float].freeze
Hsh =
Instance[Hash].freeze
Arr =
Instance[Array].freeze

Instance Method Summary collapse

Instance Method Details

#any_of(const, *consts) ⇒ Object



18
19
20
# File 'lib/uinit/type/context.rb', line 18

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

#arrayObject



79
80
81
# File 'lib/uinit/type/context.rb', line 79

def array
  Arr
end

#array_of(type) ⇒ Object



14
15
16
# File 'lib/uinit/type/context.rb', line 14

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

#booleanObject Also known as: bool



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

def boolean
  Boolean
end

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



22
23
24
# File 'lib/uinit/type/context.rb', line 22

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

#const(const) ⇒ Object



26
27
28
# File 'lib/uinit/type/context.rb', line 26

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

#floatObject



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

def float
  Float
end

#fn(arity = -1)) ⇒ Object



30
31
32
# File 'lib/uinit/type/context.rb', line 30

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

#hashObject



75
76
77
# File 'lib/uinit/type/context.rb', line 75

def hash
  Hsh
end

#hash_of(schema, strict: false) ⇒ Object



34
35
36
# File 'lib/uinit/type/context.rb', line 34

def hash_of(schema, strict: false)
  HashOf.new(schema, strict:)
end

#implObject



38
39
40
# File 'lib/uinit/type/context.rb', line 38

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

#instance(type) ⇒ Object



42
43
44
# File 'lib/uinit/type/context.rb', line 42

def instance(type)
  Instance.new(type)
end

#integerObject Also known as: int



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

def integer
  Int
end

#nilableObject Also known as: null, none



50
51
52
# File 'lib/uinit/type/context.rb', line 50

def nilable
  Nil
end

#set_of(type) ⇒ Object

rubocop:disable Naming/AccessorMethodName



46
47
48
# File 'lib/uinit/type/context.rb', line 46

def set_of(type) # rubocop:disable Naming/AccessorMethodName
  SetOf.new(type)
end

#stringObject Also known as: str



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

def string
  Str
end