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 +4 -4
- data/.yardopts +1 -0
- data/README.md +61 -13
- data/Steepfile +5 -6
- data/lib/blankity/blank.rb +65 -33
- data/lib/blankity/classes.rb +178 -90
- data/lib/blankity/to.rb +89 -50
- data/lib/blankity/{absolutely_blank.rb → top.rb} +4 -2
- data/lib/blankity/version.rb +1 -1
- data/lib/blankity.rb +1 -0
- data/sig/generated/blankity/blank.rbs +57 -10
- data/sig/generated/blankity/classes.rbs +247 -0
- data/sig/generated/blankity/to.rbs +109 -0
- data/sig/generated/blankity/top.rbs +14 -0
- data/sig/test/test/test_blank.rbs +21 -0
- data/sig/test/test/test_helper.rbs +0 -0
- data/sig/test/test/test_top.rbs +3 -0
- metadata +11 -5
- data/sig/generated/blankity/tos.rbs +0 -44
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 82b868a367489a12b73f469c8bda91b12bd4342ea50eca5014594dc852b9e77a
|
|
4
|
+
data.tar.gz: 9bc3240a45986f4781d0c69bb40614555e5be376e25ef47813f5063bea024bde
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
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
|
|
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
|
|
14
|
+
gem install blankity
|
|
21
15
|
```
|
|
22
16
|
|
|
23
17
|
## Usage
|
|
24
18
|
|
|
25
|
-
|
|
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
|
-
|
|
77
|
+
Run tests via `rake test` and `steep check`.
|
|
30
78
|
|
|
31
|
-
|
|
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/
|
|
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
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
data/lib/blankity/blank.rb
CHANGED
|
@@ -2,54 +2,86 @@
|
|
|
2
2
|
# rbs_inline: enabled
|
|
3
3
|
|
|
4
4
|
module Blankity
|
|
5
|
-
#
|
|
6
|
-
# ones of `__send__` and `__id__`.
|
|
5
|
+
# An "emptier" class than {BasicObject}, which +undef+ines nearly all instance methods.
|
|
7
6
|
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
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 `
|
|
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
|
|
20
|
+
undef_method(name) unless name.match?(/\A__.*__\z/)
|
|
14
21
|
end
|
|
15
22
|
|
|
16
|
-
#
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
#
|
|
24
|
-
|
|
25
|
-
|
|
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
|
|
28
|
-
|
|
29
|
-
end
|
|
50
|
+
# Define any object methods requested by the end-user
|
|
51
|
+
__define_Object_methods__(*methods)
|
|
30
52
|
|
|
31
|
-
|
|
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
|
-
#
|
|
35
|
-
#
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
data/lib/blankity/classes.rb
CHANGED
|
@@ -2,70 +2,66 @@
|
|
|
2
2
|
# rbs_inline: enabled
|
|
3
3
|
|
|
4
4
|
module Blankity
|
|
5
|
-
#
|
|
6
|
-
|
|
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
|
|
9
|
+
# Creates a new instance; any additional arguments or block are passed to {Blank#initialize}.
|
|
16
10
|
#
|
|
17
|
-
# @
|
|
18
|
-
|
|
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
|
-
|
|
52
|
-
|
|
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
|
-
|
|
60
|
-
|
|
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
|
-
|
|
68
|
-
|
|
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
|
-
|
|
77
|
-
|
|
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
|
-
|
|
86
|
-
|
|
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
|
-
|
|
96
|
-
|
|
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
|
-
|
|
106
|
-
|
|
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
|
-
|
|
114
|
-
|
|
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
|
-
|
|
122
|
-
|
|
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
|
-
|
|
130
|
-
|
|
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
|
|
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
|
-
|
|
138
|
-
|
|
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
|
-
|
|
146
|
-
|
|
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
|
-
|
|
154
|
-
|
|
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
|
-
|
|
162
|
-
|
|
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
|
-
|
|
170
|
-
|
|
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
|
-
|
|
185
|
-
|
|
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
|
-
|
|
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?
|