blankity 0.1.0 → 0.9.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: 34a522794c85b7f50a815a2a17e455685e5fff40512134a8652d52705fd96946
4
- data.tar.gz: 44fe6ca43f7a274e076b00c83fee4da89617102769007615a56f9e8ba8345876
3
+ metadata.gz: 82b868a367489a12b73f469c8bda91b12bd4342ea50eca5014594dc852b9e77a
4
+ data.tar.gz: 9bc3240a45986f4781d0c69bb40614555e5be376e25ef47813f5063bea024bde
5
5
  SHA512:
6
- metadata.gz: 2679a4fc2901543f1df080226bcd8d41cde7fff84ffadf084a5a3b54509bc150e5e70ed9cc138624d3a9d9d0ba09f792b11ae7253894b9d35adab64a736c4eb3
7
- data.tar.gz: 9102b667417681d9e6c52a83d3e2742513d0ff9a95efaa5925f913c9017c0a841c14ea1d414b36846797d885568547f99feffb729de7e13d012bab88508301df
6
+ metadata.gz: b322727491e488bd3c72a52b2018d5898f0e2a53049f745738bb4c22ed71647184b5b235492a17fbc103c2e5e69c72b6d1aa8035c0f0ae4dc921f36b22bfc0e7
7
+ data.tar.gz: 424882212731398452338d31e67a68d8b3832ffb8ae0bb3b924ee14290182227fe1aa1722c1d9c0844fd15f23a8328e10b67dd2907f50d0b04dab9428abb3e8b
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --type-tag rbs --hide-tag rbs
data/README.md CHANGED
@@ -1,38 +1,86 @@
1
1
  # Blankity
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
4
-
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/blankity`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Blankity is a gem that provides "blank objects," which define minimal methods.
6
4
 
7
5
  ## Installation
8
6
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
-
11
7
  Install the gem and add to the application's Gemfile by executing:
12
-
13
8
  ```bash
14
- bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
9
+ bundle add blankity
15
10
  ```
16
11
 
17
12
  If bundler is not being used to manage dependencies, install the gem by executing:
18
-
19
13
  ```bash
20
- gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
14
+ gem install blankity
21
15
  ```
22
16
 
23
17
  ## Usage
24
18
 
25
- TODO: Write usage instructions here
19
+ The `Blankity::Blank` class `undef`s all methods (other than `__send__` and `__id__`) from `BasicObject`:
20
+ ```ruby
21
+ # No methods are defined
22
+ blank = Blankity::Blank.new
23
+ p defined?(blank.==) #=> nil
24
+ p defined?(blank.inspect) #=> nil
25
+
26
+ # Include specific `Object` methods:
27
+ blank = Blankity::Blank.new(methods: [:==])
28
+ p blank == blank #=> true
29
+
30
+ # Also supports blocks, which are `instance_exec`ed
31
+ p Blankity::Blank.new { def inspect = "hi" } #=> "hi"
32
+ ```
33
+
34
+ Also supplied are `Blankity::ToXXX` classes, which just define the conversion methods that are used throughout Ruby's stdlib:
35
+ ```ruby
36
+ # String#* calls `.to_int` on its argument:
37
+ p 'a' * Blankity::ToInt.new(3) #=> "aaa"
38
+
39
+ # File.exist? calls `.to_path` on its argument:
40
+ p File.exist? Blankity::ToPath.new('/tmp/foo') #=> false
41
+
42
+ # Array#[] accepts custom ranges:
43
+ p %w[a b c d][Blankity::Range.new(1, 3)] #=> ["b", "c", "d"]
44
+
45
+ ```
46
+
47
+ As a convenience, `Blankity::To` defines these conversion methods:
48
+ ```ruby
49
+ puts 'hello' + Blankity::To.str(' world')
50
+ #=> hello world
51
+
52
+ puts 'hello'.gsub(/[eo]/, Blankity::To.hash('e' => 'E', 'o' => 'O'))
53
+ #=> hEllO
54
+ ```
55
+
56
+ The `Blankity::To` module is also a mixin!
57
+ ```ruby
58
+ extend Blankity::To
59
+
60
+ puts 'hello' + str(' world')
61
+ exit int(0)
62
+
63
+ # Let's get crazy!
64
+ system(
65
+ hash(
66
+ str('HELLO', hash: true) => str('WORLD')
67
+ ),
68
+ ary(str('sh'), str('-sh')),
69
+ str('-c'),
70
+ str('echo $0 $HELLO $PWD'),
71
+ chdir: path('/'),
72
+ )
73
+ ```
26
74
 
27
75
  ## Development
28
76
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
77
+ Run tests via `rake test` and `steep check`.
30
78
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
79
+ Before pushing new versions, make sure to run `bundle exec rbs-inline --output lib` to generate new rbs signatures, and to update the `version.rb` file.
32
80
 
33
81
  ## Contributing
34
82
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/blankity.
83
+ Bug reports and pull requests are welcome on GitHub at https://github.com/sampersand/blankity.
36
84
 
37
85
  ## License
38
86
 
data/Steepfile CHANGED
@@ -18,12 +18,11 @@ target :lib do
18
18
  # end
19
19
  end
20
20
 
21
- # target :test do
21
+ target :test do
22
22
  # unreferenced! # Skip type checking the `lib` code when types in `test` target is changed
23
23
  # signature "sig/test" # Put RBS files for tests under `sig/test`
24
- # check "test" # Type check Ruby scripts under `test`
25
-
26
- # configure_code_diagnostics(D::Ruby.lenient) # Weak type checking for test code
24
+ check "test" # Type check Ruby scripts under `test`
25
+ configure_code_diagnostics(D::Ruby.lenient) # Weak type checking for test code
26
+ gem 'rake'
27
+ end
27
28
 
28
- # # library "pathname" # Standard libraries
29
- # end
@@ -2,54 +2,86 @@
2
2
  # rbs_inline: enabled
3
3
 
4
4
  module Blankity
5
- # A "blank slate" class which removes _all_ methods (from `BasicObject`) other than the "required"
6
- # ones of `__send__` and `__id__`.
5
+ # An "emptier" class than {BasicObject}, which +undef+ines nearly all instance methods.
7
6
  #
8
- # Notably, it does not remove private instance methods, as Ruby actually requires some of them to
9
- # function properly (e.g. {BasicObject#singleton_method_added}.)
7
+ # Not _all_ methods are undefined (see {Top} for a class which does):
8
+ #
9
+ # - Methods which match +/\\A__.*__\\z/+ are not removed. Traditionally, these methods are expected
10
+ # to always be present (and +undef+ing them warns you!). Ruby has two of these: +__send__+
11
+ # and +__id__+
12
+ # - Private methods are not undefined, as each one of them is expected to be present (most of them
13
+ # are hooks, eg +singleton_method_added+), and aren't easily accessible from external classes.
14
+ #
15
+ # To make using +Blank+ easier, its constructor allows you to pass a +methods:+ keyword argument,
16
+ # which will define singleton methods based on {Object}.
10
17
  class Blank < BasicObject
11
- # Remove every method except for `__send__` and `__id__`
18
+ # Remove every public and protected method that we inherit, except for `__xyz__` methods
12
19
  instance_methods.each do |name|
13
- undef_method(name) unless name == :__send__ || name == :__id__
20
+ undef_method(name) unless name.match?(/\A__.*__\z/)
14
21
  end
15
22
 
16
- # Helper method to create a new instance
17
- #
18
- # @rbs: () ?{ (Blank) -> void } -> singleton(Blank)
19
- def self.blank(&block)
20
- ::Class.new(self, &block).new
21
- end
23
+ # Declare these as constants so we don't constantly look them up.
24
+ DEFINE_SINGLETON_METHOD = ::Object.instance_method(:define_singleton_method) #: UnboundMethod
25
+ INSTANCE_EXEC = ::Object.instance_method(:instance_exec) #: UnboundMethod
26
+ private_constant :DEFINE_SINGLETON_METHOD, :INSTANCE_EXEC
22
27
 
23
- # A helper method to define some `Kernel`methods on `self`
24
- def __with_Object_methods__(*methods)
25
- dsm = ::Object.instance_method(:define_singleton_method).bind(self)
28
+ # Creates a new {BlankValue}, and defining singleton methods depending on the parameters
29
+ #
30
+ # @param methods [Array[interned]] a list of {Object} methods to define on +self+.
31
+ # @param hash [bool] convenience argument, adds +hash+ and +eql?+ to +methods+ so the resulting
32
+ # type can be used as a key in +Hash+es
33
+ # @yield [] if a block is given, runs it via +instance_exec+.
34
+ #
35
+ # === Example
36
+ # # Make a empty instance
37
+ # Blankity::Blank.new
38
+ #
39
+ # # Include `Object#inspect`, so we can print with `p`
40
+ # p Blankity::Blank.new(methods: %i[inspect])
41
+ #
42
+ # # Define a singleton method
43
+ # p Blankity::Blank.new{ def cool?(other) = other == 3 }.cool?(3) #=> true
44
+ #
45
+ # @rbs (?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
46
+ def initialize(methods: [], hash: false, &block)
47
+ # If `hash` is supplied, then add `hash` and `eql?` to the list of methods to define
48
+ methods |= %i[hash eql?] if hash
26
49
 
27
- methods.each do |method|
28
- dsm.call(method, ::Object.instance_method(method))
29
- end
50
+ # Define any object methods requested by the end-user
51
+ __define_Object_methods__(*methods)
30
52
 
31
- self
53
+ # If a block's provided, then `instance_exec`
54
+ INSTANCE_EXEC.bind_call(self, &__any__ = block) if block
32
55
  end
33
56
 
34
- # Same as `__with_Object_methods__`, but adds them to subclasses. This shouldn't
35
- # be called on `Blankity::Blank` directly, as that affects subclasses
36
- def self.__with_Object_methods__(*methods)
37
- if ::Blankity::Blank.equal?(self)
38
- raise ArgumentError, 'Cannot call `__with_Object_methods__` on Blank, as that will affect all blank slates'
39
- end
40
-
57
+ # A helper method to define {Object} instance methods on +self+
58
+ #
59
+ # @param methods [*interned] The list of instance methods from {Object} to define
60
+ # @return [self]
61
+ #
62
+ # === Example
63
+ # # Make an empty instance
64
+ # blank = Blankity::Blank.blank
65
+ #
66
+ # # Make sure it's printable
67
+ # blank.__define_Object_methods__(:inspect, :==)
68
+ #
69
+ # # Now you can use them!
70
+ # fail unless blank == blank
71
+ # p blank
72
+ #
73
+ # @rbs (*interned) -> self
74
+ def __define_Object_methods__(*methods)
41
75
  methods.each do |method|
42
- define_method(method, ::Kernel.instance_method(method))
76
+ DEFINE_SINGLETON_METHOD.bind_call(self, method, ::Object.instance_method(method).bind(self))
43
77
  end
44
78
 
45
79
  self
46
80
  end
47
-
48
- # Helper method to create a new `Blank` with a block
49
- def self.blank(&block)
50
- ::Class.new(self, &block).new
51
- end
52
81
  end
53
82
 
54
- def self.blank(...) = Blank.blank(...)
83
+ # Shorthand constructor {Blankity::Blank}.
84
+ #
85
+ # @rbs (?methods: Array[interned], ?hash: bool) ?{ () [self: Blank] -> void } -> Blank
86
+ def self.blank(...) = Blank.new(...)
55
87
  end
@@ -2,70 +2,66 @@
2
2
  # rbs_inline: enabled
3
3
 
4
4
  module Blankity
5
- # BlankValue is a superclass of the +ToXXX+ classes, which consolidates their initialization
6
- # into one convenient place
7
- #
8
- # @rbs generic T -- type of @__value__
9
- class BlankValue < Blank
10
- # @rbs @__value__: T
11
-
12
- DEFINE_SINGLETON_METHOD = ::Kernel.instance_method(:define_singleton_method)
13
- private_constant :DEFINE_SINGLETON_METHOD
5
+ # A Class which only defines +#to_i+; it implements RBS's +_ToI+ interface.
6
+ class ToI < Blank
7
+ # @rbs @__value__: Integer
14
8
 
15
- # Creates a new {BlankValue}, and defining singleton methods depending on the parameters
9
+ # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
16
10
  #
17
- # @param value [T] the backing value for this class
18
- # @param methods [Array[interned]] a list of methods to define on +self+ that will just forward
19
- # everything to +value.<method>+
20
- # @param hash [bool] convenience argument, adds +hash+ and +eql?+ to +methods+ so the resulting
21
- # type can be used as a key in +Hash+es
22
- # @yield [] if a block is given, runs it via +instance_exec+.
23
- #
24
- # @rbs (T, ?methods: Array[interned], ?hash: bool) ?{ () [self: self] -> void } -> void
25
- def initialize(value, methods: [], hash: false, &block)
11
+ # @rbs (Integer, ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
12
+ def initialize(value, ...)
26
13
  @__value__ = value
27
-
28
- # If `hash` is supplied, then add `hash` and `eql?` to the list of methods to define
29
- methods |= %i[hash eql?] if hash
30
-
31
- methods.each do |method|
32
- # We can use `.method` instead of querying `Kernel` because all types that are used here
33
- # inherit from `Object`.
34
- DEFINE_SINGLETON_METHOD.bind_call(self, method, &@__value__.method(method))
35
- end
36
-
37
- instance_exec(&block) if block
14
+ super(...)
38
15
  end
39
- end
40
16
 
41
- # A Class which exclusively defines +#to_i+; it implements RBS's +_ToI+ interface.
42
- #
43
- # @rbs inherits BlankValue[Integer]
44
- class ToI < BlankValue
45
17
  #: () -> Integer
46
18
  def to_i = @__value__
47
19
  end
48
20
 
49
21
  # A Class which exclusively defines +#to_int+; it implements RBS's +_ToInt+ interface.
50
- #
51
- # @rbs inherits BlankValue[Integer]
52
- class ToInt < BlankValue
22
+ class ToInt < Blank
23
+ # @rbs @__value__: Integer
24
+
25
+ # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
26
+ #
27
+ # @rbs (Integer, ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
28
+ def initialize(value, ...)
29
+ @__value__ = value
30
+ super(...)
31
+ end
32
+
53
33
  #: () -> Integer
54
34
  def to_int = @__value__
55
35
  end
56
36
 
57
37
  # A Class which exclusively defines +#to_s+; it implements RBS's +_ToS+ interface.
58
- #
59
- # @rbs inherits BlankValue[String]
60
- class ToS < BlankValue
38
+ class ToS < Blank
39
+ # @rbs @__value__: String
40
+
41
+ # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
42
+ #
43
+ # @rbs (String, ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
44
+ def initialize(value, ...)
45
+ @__value__ = value
46
+ super(...)
47
+ end
48
+
61
49
  #: () -> String
62
50
  def to_s = @__value__
63
51
  end
64
52
 
65
53
  # A Class which exclusively defines +#to_str+; it implements RBS's +_ToStr+ interface.
66
- #
67
- # @rbs inherits BlankValue[String]
68
- class ToStr < BlankValue
54
+ class ToStr < Blank
55
+ # @rbs @__value__: String
56
+
57
+ # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
58
+ #
59
+ # @rbs (String, ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
60
+ def initialize(value, ...)
61
+ @__value__ = value
62
+ super(...)
63
+ end
64
+
69
65
  #: () -> String
70
66
  def to_str = @__value__
71
67
  end
@@ -73,8 +69,17 @@ module Blankity
73
69
  # A Class which exclusively defines +#to_a+; it implements RBS's +_ToA[T]+ interface.
74
70
  #
75
71
  # @rbs generic unchecked out T -- Type of elements
76
- # @rbs inherits BlankValue[Array[T]]
77
- class ToA < BlankValue
72
+ class ToA < Blank
73
+ # @rbs @__value__: Array[T]
74
+
75
+ # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
76
+ #
77
+ # @rbs (Array[T], ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
78
+ def initialize(value, ...)
79
+ @__value__ = value
80
+ super(...)
81
+ end
82
+
78
83
  #: () -> Array[T]
79
84
  def to_a = @__value__
80
85
  end
@@ -82,8 +87,17 @@ module Blankity
82
87
  # A Class which exclusively defines +#to_ary+; it implements RBS's +_ToAry[T]+ interface.
83
88
  #
84
89
  # @rbs generic unchecked out T -- Type of elements
85
- # @rbs inherits BlankValue[Array[T]]
86
- class ToAry < BlankValue
90
+ class ToAry < Blank
91
+ # @rbs @__value__: Array[T]
92
+
93
+ # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
94
+ #
95
+ # @rbs (Array[T], ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
96
+ def initialize(value, ...)
97
+ @__value__ = value
98
+ super(...)
99
+ end
100
+
87
101
  #: () -> Array[T]
88
102
  def to_ary = @__value__
89
103
  end
@@ -92,8 +106,17 @@ module Blankity
92
106
  #
93
107
  # @rbs generic unchecked out K -- Type of Key
94
108
  # @rbs generic unchecked out V -- Type of Value
95
- # @rbs inherits BlankValue[Hash[K, V]]
96
- class ToH < BlankValue
109
+ class ToH < Blank
110
+ # @rbs @__value__: Hash[K, V]
111
+
112
+ # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
113
+ #
114
+ # @rbs (Hash[K, V], ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
115
+ def initialize(value, ...)
116
+ @__value__ = value
117
+ super(...)
118
+ end
119
+
97
120
  #: () -> Hash[K, V]
98
121
  def to_h = @__value__
99
122
  end
@@ -102,72 +125,145 @@ module Blankity
102
125
  #
103
126
  # @rbs generic unchecked out K -- Type of Key
104
127
  # @rbs generic unchecked out V -- Type of Value
105
- # @rbs inherits BlankValue[Hash[K, V]]
106
- class ToHash < BlankValue
128
+ class ToHash < Blank
129
+ # @rbs @__value__: Hash[K, V]
130
+
131
+ # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
132
+ #
133
+ # @rbs (Hash[K, V], ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
134
+ def initialize(value, ...)
135
+ @__value__ = value
136
+ super(...)
137
+ end
138
+
107
139
  #: () -> Hash[K, V]
108
140
  def to_hash = @__value__
109
141
  end
110
142
 
111
143
  # A Class which exclusively defines +#to_sym+; it implements RBS's +_ToSym+ interface.
112
- #
113
- # @rbs inherits BlankValue[Symbol]
114
- class ToSym < BlankValue
144
+ class ToSym < Blank
145
+ # @rbs @__value__: Symbol
146
+
147
+ # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
148
+ #
149
+ # @rbs (Symbol, ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
150
+ def initialize(value, ...)
151
+ @__value__ = value
152
+ super(...)
153
+ end
154
+
115
155
  #: () -> Symbol
116
156
  def to_sym = @__value__
117
157
  end
118
158
 
119
159
  # A Class which exclusively defines +#to_r+; it implements RBS's +_ToR+ interface.
120
- #
121
- # @rbs inherits BlankValue[Rational]
122
- class ToR < BlankValue
160
+ class ToR < Blank
161
+ # @rbs @__value__: Rational
162
+
163
+ # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
164
+ #
165
+ # @rbs (Rational, ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
166
+ def initialize(value, ...)
167
+ @__value__ = value
168
+ super(...)
169
+ end
170
+
123
171
  #: () -> Rational
124
172
  def to_r = @__value__
125
173
  end
126
174
 
127
175
  # A Class which exclusively defines +#to_c+; it implements RBS's +_ToC+ interface.
128
- #
129
- # @rbs inherits BlankValue[Complex]
130
- class ToC < BlankValue
176
+ class ToC < Blank
177
+ # @rbs @__value__: Complex
178
+
179
+ # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
180
+ #
181
+ # @rbs (Complex, ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
182
+ def initialize(value, ...)
183
+ @__value__ = value
184
+ super(...)
185
+ end
186
+
131
187
  #: () -> Complex
132
- def to_C = @__value__
188
+ def to_c = @__value__
133
189
  end
134
190
 
135
191
  # A Class which exclusively defines +#to_f+; it implements RBS's +_ToF+ interface.
136
- #
137
- # @rbs inherits BlankValue[Float]
138
- class ToF < BlankValue
192
+ class ToF < Blank
193
+ # @rbs @__value__: Float
194
+
195
+ # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
196
+ #
197
+ # @rbs (Float, ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
198
+ def initialize(value, ...)
199
+ @__value__ = value
200
+ super(...)
201
+ end
202
+
139
203
  #: () -> Float
140
204
  def to_f = @__value__
141
205
  end
142
206
 
143
207
  # A Class which exclusively defines +#to_regexp+; it implements RBS's +Regexp::_ToRegexp+ interface.
144
- #
145
- # @rbs inherits BlankValue[Regexp]
146
- class ToRegexp < BlankValue
208
+ class ToRegexp < Blank
209
+ # @rbs @__value__: Regexp
210
+
211
+ # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
212
+ #
213
+ # @rbs (Regexp, ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
214
+ def initialize(value, ...)
215
+ @__value__ = value
216
+ super(...)
217
+ end
218
+
147
219
  #: () -> Regexp
148
220
  def to_regexp = @__value__
149
221
  end
150
222
 
151
223
  # A Class which exclusively defines +#to_path+; it implements RBS's +_ToPath+ interface.
152
- #
153
- # @rbs inherits BlankValue[String]
154
- class ToPath < BlankValue
224
+ class ToPath < Blank
225
+ # @rbs @__value__: String
226
+
227
+ # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
228
+ #
229
+ # @rbs (String, ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
230
+ def initialize(value, ...)
231
+ @__value__ = value
232
+ super(...)
233
+ end
234
+
155
235
  #: () -> String
156
236
  def to_path = @__value__
157
237
  end
158
238
 
159
239
  # A Class which exclusively defines +#to_io+; it implements RBS's +_ToIO+ interface.
160
- #
161
- # @rbs inherits BlankValue[IO]
162
- class ToIO < BlankValue
240
+ class ToIO < Blank
241
+ # @rbs @__value__: IO
242
+
243
+ # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
244
+ #
245
+ # @rbs (IO, ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
246
+ def initialize(value, ...)
247
+ @__value__ = value
248
+ super(...)
249
+ end
250
+
163
251
  #: () -> IO
164
252
  def to_io = @__value__
165
253
  end
166
254
 
167
255
  # A Class which exclusively defines +#to_proc+; it implements RBS's +_ToProc+ interface.
168
- #
169
- # @rbs inherits BlankValue[Proc]
170
- class ToProc < BlankValue
256
+ class ToProc < Blank
257
+ # @rbs @__value__: Proc
258
+
259
+ # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
260
+ #
261
+ # @rbs (Proc, ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
262
+ def initialize(value, ...)
263
+ @__value__ = value
264
+ super(...)
265
+ end
266
+
171
267
  #: () -> Proc
172
268
  def to_proc = @__value__
173
269
  end
@@ -181,23 +277,15 @@ module Blankity
181
277
  # @rbs @end: T?
182
278
  # @rbs @exclude_end: bool
183
279
 
184
- #: (T?, T?, ?bool) -> void
185
- def initialize(begin_, end_, exclude_end = false, methods: [], hash: false, &block)
280
+ # Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
281
+ #
282
+ # @rbs (T?, T?, ?bool, ?methods: Array[interned], ?hash: bool) ?{ () [self: instance] -> void } -> void
283
+ def initialize(begin_, end_, exclude_end = false, ...)
186
284
  @__begin__ = begin_
187
285
  @__end__ = end_
188
286
  @__exclude_end__ = exclude_end
189
287
 
190
- # If `hash` is supplied, then add `hash` and `eql?` to the list of methods to define
191
- methods |= %i[hash eql?] if hash
192
-
193
- methods.each do |method|
194
- p method
195
- # We can use `.method` instead of querying `Kernel` because all types that are used here
196
- # inherit from `Object`.
197
- DEFINE_SINGLETON_METHOD.bind_call(self, method, &@__value__.method(method))
198
- end
199
-
200
- instance_exec(&block) if block
288
+ super(...)
201
289
  end
202
290
 
203
291
  #: () -> T?