code-ruby 1.7.0 → 1.7.1

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/VERSION +1 -1
  4. data/lib/code/type/sig.rb +24 -4
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33ef71e66cc6f4693a344a3df19db365beb8a1c375ef74fa7fa0876bf03a4339
4
- data.tar.gz: 47b827ad96ccf65cbd3530e592ee7c804ae593c64ca31a22369a924b3a04cdfc
3
+ metadata.gz: 2ae4f4f54df6fd8223b110e202a6cfe856b7c9b693f60630910c4b3247d4b308
4
+ data.tar.gz: 43ff1552be464bc72268595e3fb72a4aaad6011f7b1f1224e4599ee7f51fffc1
5
5
  SHA512:
6
- metadata.gz: 351bf9f83d635bcafb4ef387ebd796e981c186c64ac865b17e5f6dbafa6b5bb863ced90d2521318b7c48c5f03be6de71d8c43592595ba4aeb542b6b82f5153dd
7
- data.tar.gz: 183791c8d842a780ca2721c68acc9bb15c5261ba8e0e06023b0f1bc07c867c979fb2a2889ae5faee4b1dc255f55d0dc997cbb4a26e0c0c5b49c7b0d3add0ef47
6
+ metadata.gz: d6fdc17eed4d75d91097db42fe1bf0b0d53ebaca8580fd6f8fb738c98ebdfaeb5c76a495d4d08fa17e76222d3ac4d1be357839e55438c1f04340e75f311e8227
7
+ data.tar.gz: b8028a6bc4bcda64cecf557a2cc8b730e106e0f252a1d25fda041219fc39d66407a733ddc09a6703b452e1e1bd6cd3614ea58d29ba81f433c89b40c70d3a084c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- code-ruby (1.7.0)
4
+ code-ruby (1.7.1)
5
5
  activesupport
6
6
  base64
7
7
  bigdecimal
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.7.0
1
+ 1.7.1
data/lib/code/type/sig.rb CHANGED
@@ -61,11 +61,27 @@ class Code
61
61
  max_arguments.include?(nil) ? nil : max_arguments.sum
62
62
  end
63
63
 
64
+ def min_actual_arguments
65
+ actual_arguments.size
66
+ end
67
+
68
+ def max_actual_arguments
69
+ actual_arguments.sum do |argument|
70
+ argument.is_an?(Object::Dictionary) ? argument.code_size.raw : 1
71
+ end
72
+ end
73
+
64
74
  def actual_count
65
- if actual_arguments.one?
66
- "1 argument"
75
+ if min_actual_arguments == max_actual_arguments
76
+ if min_actual_arguments == 1
77
+ "1 actual argument"
78
+ else
79
+ "#{min_actual_arguments} actual arguments"
80
+ end
81
+ elsif max_actual_arguments.nil?
82
+ "#{min_actual_arguments}+ actual arguments"
67
83
  else
68
- "#{actual_arguments.size} arguments"
84
+ "#{min_actual_arguments}-#{max_actual_arguments} actual arguments"
69
85
  end
70
86
  end
71
87
 
@@ -87,8 +103,12 @@ class Code
87
103
  max_arguments.nil? ? min_arguments.. : min_arguments..max_arguments
88
104
  end
89
105
 
106
+ def actual_range
107
+ min_actual_arguments..max_actual_arguments
108
+ end
109
+
90
110
  def check_number_of_arguments!
91
- return if expected_range.include?(actual_arguments.size)
111
+ return if expected_range.overlaps?(actual_range)
92
112
 
93
113
  raise(
94
114
  Error,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Marié