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
- #any_of(const, *consts) ⇒ Object
- #array ⇒ Object
- #array_of(type) ⇒ Object
- #boolean ⇒ Object (also: #bool)
- #check(check = nil, &proc_check) ⇒ Object
- #const(const) ⇒ Object
- #float ⇒ Object
- #fn(arity = -1)) ⇒ Object
- #hash ⇒ Object
- #impl ⇒ Object
- #integer ⇒ Object (also: #int)
- #nilable ⇒ Object (also: #null, #none)
- #schema(schema, strict: false) ⇒ Object
- #set_of(type) ⇒ Object
- #string ⇒ Object (also: #str)
- #sym ⇒ Object
- #type(type = BasicObject) ⇒ Object
- #type_of(type) ⇒ Object
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 |
#array ⇒ Object
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 |
#boolean ⇒ Object 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 |
#float ⇒ Object
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 |
#hash ⇒ Object
77 78 79 |
# File 'lib/uinit/type/context.rb', line 77 def hash Hsh end |
#impl ⇒ Object
36 37 38 |
# File 'lib/uinit/type/context.rb', line 36 def impl(*, **) Impl.new(*, **) end |
#integer ⇒ Object Also known as: int
57 58 59 |
# File 'lib/uinit/type/context.rb', line 57 def integer(**) Integer.new(**) end |
#nilable ⇒ Object 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 |
#string ⇒ Object Also known as: str
52 53 54 |
# File 'lib/uinit/type/context.rb', line 52 def string(**) String.new(**) end |
#sym ⇒ Object
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 |