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 =
TypeOf[String].freeze
- Sym =
TypeOf[Symbol].freeze
- Int =
TypeOf[Integer].freeze
- Float =
TypeOf[Float].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
- #hash_of(schema, strict: false) ⇒ Object
- #impl ⇒ Object
- #integer ⇒ Object (also: #int)
- #nilable ⇒ Object (also: #null, #none)
-
#set_of(type) ⇒ Object
rubocop:disable Naming/AccessorMethodName.
- #string ⇒ Object (also: #str)
- #sym ⇒ Object
- #type(type = BasicObject) ⇒ Object
- #type_of(type) ⇒ Object
Instance Method Details
#any_of(const, *consts) ⇒ Object
19 20 21 |
# File 'lib/uinit/type/context.rb', line 19 def any_of(const, *consts) consts.reduce(Const[const]) { |type, cst| type | Const[cst] } end |
#array ⇒ Object
84 85 86 |
# File 'lib/uinit/type/context.rb', line 84 def array Arr end |
#array_of(type) ⇒ Object
15 16 17 |
# File 'lib/uinit/type/context.rb', line 15 def array_of(type) ArrayOf.new(type) end |
#boolean ⇒ Object Also known as: bool
61 62 63 |
# File 'lib/uinit/type/context.rb', line 61 def boolean Boolean end |
#check(check = nil, &proc_check) ⇒ Object
23 24 25 |
# File 'lib/uinit/type/context.rb', line 23 def check(check = nil, &proc_check) Check.new(check || proc_check) end |
#const(const) ⇒ Object
27 28 29 |
# File 'lib/uinit/type/context.rb', line 27 def const(const) Const.new(const) end |
#float ⇒ Object
76 77 78 |
# File 'lib/uinit/type/context.rb', line 76 def float Float end |
#fn(arity = -1)) ⇒ Object
31 32 33 |
# File 'lib/uinit/type/context.rb', line 31 def fn(arity = -1) Fn.new(arity) end |
#hash ⇒ Object
80 81 82 |
# File 'lib/uinit/type/context.rb', line 80 def hash Hsh end |
#hash_of(schema, strict: false) ⇒ Object
35 36 37 |
# File 'lib/uinit/type/context.rb', line 35 def hash_of(schema, strict: false) HashOf.new(schema, strict:) end |
#impl ⇒ Object
39 40 41 |
# File 'lib/uinit/type/context.rb', line 39 def impl(*, **) Impl.new(*, **) end |
#integer ⇒ Object Also known as: int
71 72 73 |
# File 'lib/uinit/type/context.rb', line 71 def integer Int end |
#nilable ⇒ Object Also known as: null, none
55 56 57 |
# File 'lib/uinit/type/context.rb', line 55 def nilable Nil end |
#set_of(type) ⇒ Object
rubocop:disable Naming/AccessorMethodName
43 44 45 |
# File 'lib/uinit/type/context.rb', line 43 def set_of(type) # rubocop:disable Naming/AccessorMethodName SetOf.new(type) end |
#string ⇒ Object Also known as: str
66 67 68 |
# File 'lib/uinit/type/context.rb', line 66 def string Str end |
#sym ⇒ Object
88 89 90 |
# File 'lib/uinit/type/context.rb', line 88 def sym Sym end |