blankity 0.10.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6073dd5657ac15bdd561c7438da0dd3fb890e82d50953f479a2b2dceb40dbdbf
4
- data.tar.gz: 28ae49ee61fe6d2d6e0b785f95a57a77b1ba35fe0c5aa7d94086ab6510f495f6
3
+ metadata.gz: 9df0df8fd886ec2a81641d73014b4be0b527a660fcba506edb70678f37414125
4
+ data.tar.gz: 1d4bc2db327cfae657ea66ac46c713dcc8778a2a5e3e2f82bb2e71aeb706611e
5
5
  SHA512:
6
- metadata.gz: f5f7213d2521ab96d21139443fdb6e8d634b6dc3564d6e7f04fdc3887149b5fff126ad8cb4fa53d7a2884416614b3f5364cf8086172774ada77eb41a0302532b
7
- data.tar.gz: 18b221c650794e50faa44bd9830f561bf3be7402e2f66caac22c9ba3fa998b10ad6950cf380952369804c2397cffd35d9ef5ea7c1b279f79d8ca7db49001f0b4
6
+ metadata.gz: '09a5c2ed58492f5943bd548726302f90296d392a1f654bc25507ab64fef10b298cd415f1b0063fc121dfeea48998ef5f7728ba39e5878e189a00c8b9403482ec'
7
+ data.tar.gz: ad5b3b4fafa74d980b7aa145b96accc7ea795fc1111b59c0bb22469d799ecaf6930b04fdd4a0b09600086ff24dfa54e0cbec9661a59066ba0662e6ba592cffba
data/README.md CHANGED
@@ -53,22 +53,22 @@ puts 'hello'.gsub(/[eo]/, Blankity::To.hash('e' => 'E', 'o' => 'O'))
53
53
  #=> hEllO
54
54
  ```
55
55
 
56
- The `Blankity::To` module is also a mixin!
56
+ You can include the `Blankity::To` module to get theeh `theo` method!
57
57
  ```ruby
58
58
  extend Blankity::To
59
59
 
60
- puts 'hello' + str(' world')
61
- exit int(0)
60
+ puts 'hello' + to.str(' world')
61
+ exit to.int(0)
62
62
 
63
63
  # Let's get crazy!
64
64
  system(
65
- hash(
66
- str('HELLO', hash: true) => str('WORLD')
65
+ to.hash(
66
+ to.str('HELLO', hash: true) => to.str('WORLD')
67
67
  ),
68
- ary(str('sh'), str('-sh')),
69
- str('-c'),
70
- str('echo $0 $HELLO $PWD'),
71
- chdir: path('/'),
68
+ to.ary(to.str('sh'), to.str('-sh')),
69
+ to.str('-c'),
70
+ to.str('echo $0 $HELLO $PWD'),
71
+ chdir: to.path('/'),
72
72
  )
73
73
  ```
74
74
 
@@ -20,8 +20,10 @@ module Blankity
20
20
  # @rbs!
21
21
  # def __define_singleton_method__: (interned name, Method | UnboundMethod | Proc method) -> Symbol
22
22
  # | (interned name) { (?) [self: self] -> untyped } -> Symbol
23
- # def __instance_exec__: [T] (*untyped, **untyped) { (?) [self: self] -> T } -> T
24
23
  define_method :__define_singleton_method__, ::Kernel.instance_method(:define_singleton_method)
24
+
25
+ # @rbs!
26
+ # def __instance_exec__: [T] (*untyped, **untyped) { (?) [self: self] -> T } -> T
25
27
  alias_method :__instance_exec__, :instance_exec # Use `alias_method` instead of `alias` so rbs-inline won't pick it up
26
28
 
27
29
  # Remove every other public and protected method that we inherit, except for `__xyz__` methods
@@ -36,6 +38,7 @@ module Blankity
36
38
 
37
39
  # Creates a new {BlankValue}, and defining singleton methods depending on the parameters
38
40
  #
41
+ # @param vars [Hash[interned, untyped]] an array of instance variables to define on +self+.
39
42
  # @param with [Array[interned]] a list of {Object} methods to define on +self+.
40
43
  # @param hash [bool] convenience argument, adds +hash+ and +eql?+ to +with+ so the resulting
41
44
  # type can be used as a key in +Hash+es
@@ -51,8 +54,8 @@ module Blankity
51
54
  # # Define a singleton method
52
55
  # p Blankity::Blank.new{ def cool?(other) = other == 3 }.cool?(3) #=> true
53
56
  #
54
- # @rbs (?with: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
55
- def initialize(with: [], hash: false, &block)
57
+ # @rbs (?vars: Hash[interned, untyped], ?with: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
58
+ def initialize(vars: {}, with: [], hash: false, &block)
56
59
  # If `hash` is supplied, then add `hash` and `eql?` to the list of methods to define
57
60
  with |= %i[hash eql?] if hash
58
61
 
@@ -61,6 +64,11 @@ module Blankity
61
64
  __define_singleton_method__(method, ::Object.instance_method(method).bind(self))
62
65
  end
63
66
 
67
+ # Assign all instance variables
68
+ vars.each do |key, value|
69
+ ::Kernel.instance_method(:instance_variable_set).bind_call(self, key, value)
70
+ end
71
+
64
72
  # If a block's provided, then `instance_exec`
65
73
  __instance_exec__(&__any__ = block) if block
66
74
  end
data/lib/blankity/to.rb CHANGED
@@ -4,56 +4,44 @@
4
4
  module Blankity
5
5
  # Convenience methods for creating new +BlankIty::ToXXX+ instances.
6
6
  #
7
- # Using +To+ as a mixin (via +extend+ / +include+ / +prepend+) isn't suggested, as {Kernel#proc}
8
- # and {Kernel#hash} will be overwritten. Attempting to do so will emit a warning if `$VERBOSE` is
9
- # enabled.
7
+ # This module can be +include+/+extend+ed to define the `to` function, which lets you do things
8
+ # like +system to.str('ls -al')+. (The module is not mixin-able, as it overwrites {Kernel} methods,
9
+ # notably +proc+ and +hash+).
10
10
  module To
11
- # Warn when including +To+
12
- def self.included(mod)
13
- $VERBOSE and warn 'including Blankity::To overwrites Kernel#proc and Kernel#hash', uplevel: 1
14
- end
15
-
16
- # Warn when extending +To+
17
- def self.extended(mod)
18
- $VERBOSE and warn 'extending Blankity::To overwrites Kernel#proc and Kernel#hash', uplevel: 1
19
- end
20
-
21
- # Warn when prepending +To+
22
- def self.prepended(mod)
23
- $VERBOSE and warn 'prepending Blankity::To overwrites Kernel#proc and Kernel#hash', uplevel: 1
24
- end
25
-
26
- module_function
11
+ # Helper method so you can `include Blankity::To` and then `to.str(...)`.
12
+ #
13
+ # @rbs () -> singleton(Blankity::To)
14
+ module_function def to = ::Blankity::To
27
15
 
28
16
  # Convenience method to make {ToI}s from +value.to_i+
29
17
  #
30
- # @rbs (_ToI, ?methods: Array[interned], ?hash: bool) ?{ () [self: ToI] -> void } -> ToI
31
- def i(value, ...) = ToI.new(value.to_i, ...)
18
+ # @rbs (_ToI, ?with: Array[interned], ?hash: bool) ?{ () [self: ToI] -> void } -> ToI
19
+ def self.i(value, ...) = ToI.new(value.to_i, ...)
32
20
 
33
21
  # Convenience method to make {ToInt}s from +value.to_int+
34
22
  #
35
- # @rbs (int, ?methods: Array[interned], ?hash: bool) ?{ () [self: ToInt] -> void } -> ToInt
36
- def int(value, ...) = ToInt.new(value.to_int, ...)
23
+ # @rbs (int, ?with: Array[interned], ?hash: bool) ?{ () [self: ToInt] -> void } -> ToInt
24
+ def self.int(value, ...) = ToInt.new(value.to_int, ...)
37
25
 
38
26
  # Convenience method to make {ToS}s from +value.to_s+
39
27
  #
40
- # @rbs (_ToS, ?methods: Array[interned], ?hash: bool) ?{ () [self: ToS] -> void } -> ToS
41
- def s(value, ...) = ToS.new(value.to_s, ...)
28
+ # @rbs (_ToS, ?with: Array[interned], ?hash: bool) ?{ () [self: ToS] -> void } -> ToS
29
+ def self.s(value, ...) = ToS.new(value.to_s, ...)
42
30
 
43
31
  # Convenience method to make {ToStr}s from +value.to_str+
44
32
  #
45
- # @rbs (string, ?methods: Array[interned], ?hash: bool) ?{ () [self: ToStr] -> void } -> ToStr
46
- def str(value, ...) = ToStr.new(value.to_str, ...)
33
+ # @rbs (string, ?with: Array[interned], ?hash: bool) ?{ () [self: ToStr] -> void } -> ToStr
34
+ def self.str(value, ...) = ToStr.new(value.to_str, ...)
47
35
 
48
36
  # Convenience method to make {ToA}s from +elements+
49
37
  #
50
- # @rbs [T] (*T, ?methods: Array[interned], ?hash: bool) ?{ () [self: ToA[T]] -> void } -> ToA[T]
51
- def a(*elements, **, &) = ToA.new(elements, **, &)
38
+ # @rbs [T] (*T, ?with: Array[interned], ?hash: bool) ?{ () [self: ToA[T]] -> void } -> ToA[T]
39
+ def self.a(*elements, **, &) = ToA.new(elements, **, &)
52
40
 
53
41
  # Convenience method to make {ToAry}s from +elements+
54
42
  #
55
- # @rbs [T] (*T, ?methods: Array[interned], ?hash: bool) ?{ () [self: ToAry[T]] -> void } -> ToAry[T]
56
- def ary(*elements, **, &) = ToAry.new(elements, **, &)
43
+ # @rbs [T] (*T, ?with: Array[interned], ?hash: bool) ?{ () [self: ToAry[T]] -> void } -> ToAry[T]
44
+ def self.ary(*elements, **, &) = ToAry.new(elements, **, &)
57
45
 
58
46
  # Convenience method to make {ToH}s from +hash+
59
47
  #
@@ -61,9 +49,9 @@ module Blankity
61
49
  # shorthand, but you can't then pass keyword arguments to {ToH}'s constructor. To do so, instead
62
50
  # pass in a Hash as a positional argument (e.g. +Blankity::To.h({ 'a' => 'b' }, ...)+)
63
51
  #
64
- # @rbs [K, V] (_ToH[K, V], ?methods: Array[interned], ?hash: bool) ?{ () [self: ToH[K, V]] -> void } -> ToH[K, V]
52
+ # @rbs [K, V] (_ToH[K, V], ?with: Array[interned], ?hash: bool) ?{ () [self: ToH[K, V]] -> void } -> ToH[K, V]
65
53
  # | [K, V] (**V) ?{ () [self: ToH[K, V]] -> void } -> ToH[K, V]
66
- def h(hash = nil, **, &)
54
+ def self.h(hash = nil, **, &)
67
55
  if hash
68
56
  ToH.new(hash.to_h, **, &)
69
57
  else
@@ -77,9 +65,9 @@ module Blankity
77
65
  # shorthand, but you can't then pass keyword arguments to {ToHash}'s constructor. To do so, instead
78
66
  # pass in a Hash as a positional argument (e.g. +Blankity::To.hash({ 'a' => 'b' }, ...)+)
79
67
  #
80
- # @rbs [K, V] (hash[K, V], ?methods: Array[interned], ?hash: bool) ?{ () [self: ToHash[K, V]] -> void } -> ToHash[K, V]
68
+ # @rbs [K, V] (hash[K, V], ?with: Array[interned], ?hash: bool) ?{ () [self: ToHash[K, V]] -> void } -> ToHash[K, V]
81
69
  # | [K, V] (**V) ?{ () [self: ToHash[K, V]] -> void } -> ToHash[K, V]
82
- def hash(hash = nil, **, &)
70
+ def self.hash(hash = nil, **, &)
83
71
  if hash
84
72
  ToHash.new(hash.to_hash, **, &)
85
73
  else
@@ -89,39 +77,39 @@ module Blankity
89
77
 
90
78
  # Convenience method to make {ToSym}s from +value.to_sym+
91
79
  #
92
- # @rbs (_ToSym, ?methods: Array[interned], ?hash: bool) ?{ () [self: ToSym] -> void } -> ToSym
93
- def sym(value, ...) = ToSym.new(value.to_sym, ...)
80
+ # @rbs (_ToSym, ?with: Array[interned], ?hash: bool) ?{ () [self: ToSym] -> void } -> ToSym
81
+ def self.sym(value, ...) = ToSym.new(value.to_sym, ...)
94
82
 
95
83
  # Convenience method to make {ToR}s from +value.to_r+
96
84
  #
97
- # @rbs (_ToR, ?methods: Array[interned], ?hash: bool) ?{ () [self: ToR] -> void } -> ToR
98
- def r(value, ...) = ToR.new(value.to_r, ...)
85
+ # @rbs (_ToR, ?with: Array[interned], ?hash: bool) ?{ () [self: ToR] -> void } -> ToR
86
+ def self.r(value, ...) = ToR.new(value.to_r, ...)
99
87
 
100
88
  # Convenience method to make {ToC}s from +value.to_c+
101
89
  #
102
- # @rbs (_ToC, ?methods: Array[interned], ?hash: bool) ?{ () [self: ToC] -> void } -> ToC
103
- def c(value, ...) = ToC.new(value.to_c, ...)
90
+ # @rbs (_ToC, ?with: Array[interned], ?hash: bool) ?{ () [self: ToC] -> void } -> ToC
91
+ def self.c(value, ...) = ToC.new(value.to_c, ...)
104
92
 
105
93
  # Convenience method to make {ToF}s from +value.to_f+
106
94
  #
107
- # @rbs (float, ?methods: Array[interned], ?hash: bool) ?{ () [self: ToF] -> void } -> ToF
108
- def f(value, ...) = ToF.new(value.to_f, ...)
95
+ # @rbs (float, ?with: Array[interned], ?hash: bool) ?{ () [self: ToF] -> void } -> ToF
96
+ def self.f(value, ...) = ToF.new(value.to_f, ...)
109
97
 
110
98
  # Convenience method to make {ToRegexp}s from +value.to_regexp+
111
99
  #
112
- # @rbs (Regexp::_ToRegexp | Regexp, ?methods: Array[interned], ?hash: bool) ?{ () [self: ToRegexp] -> void } -> ToRegexp
113
- def regexp(value, ...) = ToRegexp.new(Regexp === value ? value : value.to_regexp, ...)
100
+ # @rbs (Regexp::_ToRegexp | Regexp, ?with: Array[interned], ?hash: bool) ?{ () [self: ToRegexp] -> void } -> ToRegexp
101
+ def self.regexp(value, ...) = ToRegexp.new(Regexp === value ? value : value.to_regexp, ...)
114
102
 
115
103
  # Convenience method to make {ToPath}s from +value.to_path+, or +Kernel#String(value)+
116
104
  # if +value+ doesn't define +#to_path+.
117
105
  #
118
- # @rbs (path, ?methods: Array[interned], ?hash: bool) ?{ () [self: ToPath] -> void } -> ToPath
119
- def path(value, ...) = ToPath.new(defined?(value.to_path) ? value.to_path : String(value), ...)
106
+ # @rbs (path, ?with: Array[interned], ?hash: bool) ?{ () [self: ToPath] -> void } -> ToPath
107
+ def self.path(value, ...) = ToPath.new(defined?(value.to_path) ? value.to_path : String(value), ...)
120
108
 
121
109
  # Convenience method to make {ToIO}s from +value.to_io+
122
110
  #
123
- # @rbs (io, ?methods: Array[interned], ?hash: bool) ?{ () [self: ToIO] -> void } -> ToIO
124
- def io(value, ...) = ToIO.new(value.to_io, ...)
111
+ # @rbs (io, ?with: Array[interned], ?hash: bool) ?{ () [self: ToIO] -> void } -> ToIO
112
+ def self.io(value, ...) = ToIO.new(value.to_io, ...)
125
113
 
126
114
  # Convenience method to make {ToProc}s from the supplied block, or +proc+ if no block is given.
127
115
  #
@@ -129,8 +117,8 @@ module Blankity
129
117
  # shorthand, but then you can't pass a block to {ToProc}'s constructor. To so do, instead pass
130
118
  # the block as a positional parameter (eg +Blankity::To.proc(proc { ... }) { ... }+)
131
119
  #
132
- # @rbs (_ToProc, ?methods: Array[interned], ?hash: bool) ?{ () [self: ToProc] -> void } -> ToProc
133
- # | (?methods: Array[interned], ?hash: bool) { (?) -> untyped } -> ToProc
120
+ # @rbs (_ToProc, ?with: Array[interned], ?hash: bool) ?{ () [self: ToProc] -> void } -> ToProc
121
+ # | (?with: Array[interned], ?hash: bool) { (?) -> untyped } -> ToProc
134
122
  def self.proc(proc = nil, **, &block)
135
123
  if proc
136
124
  ToProc.new(proc.to_proc, **, &block)
@@ -143,10 +131,9 @@ module Blankity
143
131
 
144
132
  # Convenience method to make {Range}s from the supplied arguments.
145
133
  #
146
- # @rbs [T] (T?, T?, ?bool, ?methods: Array[interned], ?hash: bool) ?{ () [self: Range[T]] -> void } -> Range[T]
147
- def range(begin_, end_, exclude_end = false, ...)
134
+ # @rbs [T] (T?, T?, ?bool, ?with: Array[interned], ?hash: bool) ?{ () [self: Range[T]] -> void } -> Range[T]
135
+ def self.range(begin_, end_, exclude_end = false, ...)
148
136
  __any__ = Range.new(begin_, end_, exclude_end, ...)
149
137
  end
150
138
  end
151
139
  end
152
-
@@ -0,0 +1,166 @@
1
+ # frozen_string_literal: true
2
+ # rbs_inline: enabled
3
+
4
+ module Blankity
5
+ # @rbs generic T
6
+ class Value < Blank
7
+ # The underlying value
8
+ attr_reader :__value__ #: T
9
+
10
+ # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
11
+ #
12
+ # @rbs (T, ?with: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
13
+ def initialize(value, ...)
14
+ @__value__ = value
15
+ super(...)
16
+ end
17
+ end
18
+
19
+ # A Class which only defines +#to_i+; it implements RBS's +_ToI+ interface.
20
+ #
21
+ # @rbs inherits Value[Integer]
22
+ class ToI < Value
23
+ alias to_i __value__
24
+ end
25
+
26
+ # A Class which exclusively defines +#to_int+; it implements RBS's +_ToInt+ interface.
27
+ #
28
+ # @rbs inherits Value[Integer]
29
+ class ToInt < Value
30
+ alias to_int __value__
31
+ end
32
+
33
+ # A Class which exclusively defines +#to_s+; it implements RBS's +_ToS+ interface.
34
+ #
35
+ # @rbs inherits Value[String]
36
+ class ToS < Value
37
+ alias to_s __value__
38
+ end
39
+
40
+ # A Class which exclusively defines +#to_str+; it implements RBS's +_ToStr+ interface.
41
+ #
42
+ # @rbs inherits Value[String]
43
+ class ToStr < Value
44
+ alias to_str __value__
45
+ end
46
+
47
+ # A Class which exclusively defines +#to_a+; it implements RBS's +_ToA[T]+ interface.
48
+ #
49
+ # @rbs generic unchecked out T -- Type of elements
50
+ # @rbs inherits Value[Array[T]]
51
+ class ToA < Value
52
+ alias to_a __value__
53
+ end
54
+
55
+ # A Class which exclusively defines +#to_ary+; it implements RBS's +_ToAry[T]+ interface.
56
+ #
57
+ # @rbs generic unchecked out T -- Type of elements
58
+ # @rbs inherits Value[Array[T]]
59
+ class ToAry < Value
60
+ alias to_ary __value__
61
+ end
62
+
63
+ # A Class which exclusively defines +#to_h+; it implements RBS's +_ToH[K, V]+ interface.
64
+ #
65
+ # @rbs generic unchecked out K -- Type of Key
66
+ # @rbs generic unchecked out V -- Type of Value
67
+ # @rbs inherits Value[Hash[K, V]]
68
+ class ToH < Value
69
+ alias to_h __value__
70
+ end
71
+
72
+ # A Class which exclusively defines +#to_hash+; it implements RBS's +_ToHash[K, V]+ interface.
73
+ #
74
+ # @rbs generic unchecked out K -- Type of Key
75
+ # @rbs generic unchecked out V -- Type of Value
76
+ # @rbs inherits Value[Hash[K, V]]
77
+ class ToHash < Value
78
+ alias to_hash __value__
79
+ end
80
+
81
+ # A Class which exclusively defines +#to_sym+; it implements RBS's +_ToSym+ interface.
82
+ #
83
+ # @rbs inherits Value[Symbol]
84
+ class ToSym < Value
85
+ alias to_sym __value__
86
+ end
87
+
88
+ # A Class which exclusively defines +#to_r+; it implements RBS's +_ToR+ interface.
89
+ #
90
+ # @rbs inherits Value[Rational]
91
+ class ToR < Value
92
+ alias to_r __value__
93
+ end
94
+
95
+ # A Class which exclusively defines +#to_c+; it implements RBS's +_ToC+ interface.
96
+ #
97
+ # @rbs inherits Value[Complex]
98
+ class ToC < Value
99
+ alias to_c __value__
100
+ end
101
+
102
+ # A Class which exclusively defines +#to_f+; it implements RBS's +_ToF+ interface.
103
+ #
104
+ # @rbs inherits Value[Float]
105
+ class ToF < Value
106
+ alias to_f __value__
107
+ end
108
+
109
+ # A Class which exclusively defines +#to_regexp+; it implements RBS's +Regexp::_ToRegexp+ interface.
110
+ #
111
+ # @rbs inherits Value[Regexp]
112
+ class ToRegexp < Value
113
+ alias to_regexp __value__
114
+ end
115
+
116
+ # A Class which exclusively defines +#to_path+; it implements RBS's +_ToPath+ interface.
117
+ #
118
+ # @rbs inherits Value[String]
119
+ class ToPath < Value
120
+ alias to_path __value__
121
+ end
122
+
123
+ # A Class which exclusively defines +#to_io+; it implements RBS's +_ToIO+ interface.
124
+ #
125
+ # @rbs inherits Value[IO]
126
+ class ToIO < Value
127
+ alias to_io __value__
128
+ end
129
+
130
+ # A Class which exclusively defines +#to_proc+; it implements RBS's +_ToProc+ interface.
131
+ #
132
+ # @rbs inherits Value[Proc]
133
+ class ToProc < Value
134
+ alias to_proc __value__
135
+ end
136
+
137
+ # A Class which defines `#begin`, `#end`, and `#exclude_end?`. It implements RBS's +_Range[T]+
138
+ # interface.
139
+ #
140
+ # @rbs generic out T -- Type to iterate over
141
+ class Range < Blank
142
+ # @rbs @__begin__: T?
143
+ # @rbs @__end__: T?
144
+ # @rbs @__exclude_end__: bool
145
+
146
+ # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
147
+ #
148
+ # @rbs (T?, T?, ?bool, ?with: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
149
+ def initialize(begin_, end_, exclude_end = false, ...)
150
+ @__begin__ = begin_
151
+ @__end__ = end_
152
+ @__exclude_end__ = exclude_end
153
+
154
+ super(...)
155
+ end
156
+
157
+ # @rbs () -> T?
158
+ def begin = @__begin__
159
+
160
+ # @rbs () -> T?
161
+ def end = @__end__
162
+
163
+ # @rbs () -> bool
164
+ def exclude_end? = @__exclude_end__
165
+ end
166
+ end
@@ -2,5 +2,5 @@
2
2
  # rbs_inline: enabled
3
3
 
4
4
  module Blankity
5
- VERSION = '0.10.1'
5
+ VERSION = '1.0.0'
6
6
  end
data/lib/blankity.rb CHANGED
@@ -11,5 +11,5 @@ end
11
11
  require_relative 'blankity/version'
12
12
  require_relative 'blankity/top'
13
13
  require_relative 'blankity/blank'
14
- require_relative 'blankity/classes'
14
+ require_relative 'blankity/value'
15
15
  require_relative 'blankity/to'
@@ -11,7 +11,7 @@ module Blankity
11
11
  # - Private methods are not undefined, as each one of them is expected to be present (most of them
12
12
  # are hooks, eg +singleton_method_added+), and aren't easily accessible from external classes.
13
13
  #
14
- # To make using +Blank+ easier, its constructor allows you to pass a +methods:+ keyword argument,
14
+ # To make using +Blank+ easier, its constructor allows you to pass a +with:+ keyword argument,
15
15
  # which will define singleton methods based on {Object}.
16
16
  class Blank < BasicObject
17
17
  def __define_singleton_method__: (interned name, Method | UnboundMethod | Proc method) -> Symbol
@@ -19,12 +19,13 @@ module Blankity
19
19
 
20
20
  def __instance_exec__: [T] (*untyped, **untyped) { (?) [self: self] -> T } -> T
21
21
 
22
+ # Alias for `new`
22
23
  alias self.blank self.new
23
24
 
24
25
  # Creates a new {BlankValue}, and defining singleton methods depending on the parameters
25
26
  #
26
- # @param methods [Array[interned]] a list of {Object} methods to define on +self+.
27
- # @param hash [bool] convenience argument, adds +hash+ and +eql?+ to +methods+ so the resulting
27
+ # @param with [Array[interned]] a list of {Object} methods to define on +self+.
28
+ # @param hash [bool] convenience argument, adds +hash+ and +eql?+ to +with+ so the resulting
28
29
  # type can be used as a key in +Hash+es
29
30
  # @yield [] if a block is given, runs it via +__instance_exec__+.
30
31
  #
@@ -33,17 +34,12 @@ module Blankity
33
34
  # Blankity::Blank.new
34
35
  #
35
36
  # # Include `Object#inspect`, so we can print with `p`
36
- # p Blankity::Blank.new(methods: %i[inspect])
37
+ # p Blankity::Blank.new(with: %i[inspect])
37
38
  #
38
39
  # # Define a singleton method
39
40
  # p Blankity::Blank.new{ def cool?(other) = other == 3 }.cool?(3) #=> true
40
41
  #
41
- # @rbs (?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
42
- def initialize: (?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
42
+ # @rbs (?with: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
43
+ def initialize: (?with: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
43
44
  end
44
-
45
- # Shorthand constructor {Blankity::Blank}.
46
- #
47
- # @rbs (?methods: Array[interned], ?hash: bool) ?{ () [self: Blank] -> void } -> Blank
48
- def self.blank: (?methods: Array[interned], ?hash: bool) ?{ () [self: Blank] -> void } -> Blank
49
45
  end