numbers_and_words 1.1.0 → 1.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b1d0985b1d262b3a78fde2e6c1c342d6d0eaa59b0e9bd785f63d13929f62041
4
- data.tar.gz: 4fe154a8cf9a28f17cff59122b2c1b498976f89310186ce93fa8ccbf2d209e09
3
+ metadata.gz: fb15b755a6c55ed0ec55ac20c9ea4d713d2d6109ff74337da35ed9c060c3c242
4
+ data.tar.gz: 743dfdc79f9f1f0f08bea129a33737bfb04e90dfd8d8d3c69af07cc3c4f67011
5
5
  SHA512:
6
- metadata.gz: 6807ba34c9ff66636820c673d18a428f8b4a044d0c3a63034909ea4b63d97a242939bc6b88aaa7d4405b0dab3e806c1cacafc6132a7372fee5f2b8ef38475752
7
- data.tar.gz: 18c604ec45b296d7617681a00161dd3be0666e422ad2fe7575364417452363d7c09b925fbd7c1e71596b7232eb89ca6f1892d9ded8efbb32199fe750ac9356bc
6
+ metadata.gz: 61560d6f23d15758bb6c7eb2fbf65865abe6fd42d5052588d2e0a4e59dcaca6f8e44a9aed7e0f35380f68bf9960d39b01a84567c6c06dd3ac6091efc2980e9a5
7
+ data.tar.gz: e06a099aad6fe260b20b47726e4dbd73619ae8a1836c1accfa6c227ac11005c3a5ed4ffa538cd21024d2ee821789f218fed3d0523e101ea3c3363fea935ce6cd
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 1.1.1 (2026/11/22)
2
+
3
+ ### Bugs
4
+
5
+ * Raise `RangeError` for Brazilian Portuguese ordinals of 10**36 and more, instead of spelling them without their highest digits. \[[#325](https://github.com/kslazarev/numbers_and_words/pull/325)\] \([@dblock](https://github.com/dblock)\)
6
+ * Answer `respond_to?` on the options proxy instead of raising `ArgumentError`. \[[#346](https://github.com/kslazarev/numbers_and_words/pull/346)\] \([@dblock](https://github.com/dblock)\)
7
+ * Return no words for `0.to_words(ordinal: true, remove_zero: true)` instead of raising `NoMethodError` in Azerbaijani, Dutch, French, German, Norwegian and Swiss French, or returning the ordinal prefix alone in Chinese, Japanese, Korean, Thai and Vietnamese, and spell the ordinal of zero in Russian and Ukrainian. \[[#344](https://github.com/kslazarev/numbers_and_words/pull/344)\] \([@dblock](https://github.com/dblock)\)
8
+
1
9
  ## 1.1.0 (2026/11/22)
2
10
 
3
11
  ### Features
@@ -17,7 +17,7 @@ module NumbersAndWords
17
17
 
18
18
  def words
19
19
  result = super
20
- @options.ordinal&.result ? ordinal(result) : result
20
+ @options.ordinal&.result && !result.empty? ? ordinal(result) : result
21
21
  end
22
22
 
23
23
  def print_words
@@ -40,7 +40,7 @@ module NumbersAndWords
40
40
  # the earlier spelling ("trois cent vingt et un").
41
41
  def print_words
42
42
  words = @options.spelling.traditional? ? super : hyphenate(super)
43
- ordinal? ? ordinal(words) : words
43
+ ordinal? && !words.empty? ? ordinal(words) : words
44
44
  end
45
45
 
46
46
  private
@@ -14,7 +14,7 @@ module NumbersAndWords
14
14
  def words
15
15
  number = @figures.to_a.reverse.join.to_i
16
16
  text = number.zero? ? zero_words : number_words(groups(number))
17
- ordinal? ? "#{ordinal_prefix}#{text}" : text
17
+ ordinal? && !text.empty? ? "#{ordinal_prefix}#{text}" : text
18
18
  end
19
19
 
20
20
  # The fractional part of a decimal, digit by digit and with its leading zeros: 3.05 ends with 0 and 5.
@@ -16,7 +16,7 @@ module NumbersAndWords
16
16
  raise Translations::Families::Base.range_error(Math.log10(MAX).to_i) if number >= MAX
17
17
 
18
18
  text = number.zero? ? zero_words : number_words(number)
19
- ordinal? ? ordinal_words(text) : text
19
+ ordinal? && !text.empty? ? ordinal_words(text) : text
20
20
  end
21
21
 
22
22
  private
@@ -10,7 +10,7 @@ module NumbersAndWords
10
10
  module Ordinals
11
11
  def words
12
12
  text = super
13
- ordinal_number? ? ordinal_words(text, ordinal_integer) : text
13
+ ordinal_number? && !text.empty? ? ordinal_words(text, ordinal_integer) : text
14
14
  end
15
15
 
16
16
  private
@@ -8,9 +8,9 @@ module NumbersAndWords
8
8
  prepend Cases
9
9
  prepend Ordinals
10
10
 
11
- # remove_zero: true omits a zero integral part.
11
+ # remove_zero: true omits a zero integral part, but not the ordinal of zero ("нулевой"), as in Bulgarian.
12
12
  def zero(*args)
13
- super unless @options.remove_zero.result
13
+ super unless @options.remove_zero.result && !ordinal_number?
14
14
  end
15
15
 
16
16
  include Families::Cyrillic
@@ -13,7 +13,7 @@ module NumbersAndWords
13
13
  def words
14
14
  number = @figures.to_a.reverse.join.to_i
15
15
  text = number.zero? ? zero_words : number_words(number)
16
- ordinal? ? "#{@translations.t(:ordinal_prefix)}#{text}" : text
16
+ ordinal? && !text.empty? ? "#{@translations.t(:ordinal_prefix)}#{text}" : text
17
17
  end
18
18
 
19
19
  private
@@ -8,9 +8,9 @@ module NumbersAndWords
8
8
  prepend Cases
9
9
  prepend Ordinals
10
10
 
11
- # remove_zero: true omits a zero integral part.
11
+ # remove_zero: true omits a zero integral part, but not the ordinal of zero ("нулевой"), as in Bulgarian.
12
12
  def zero(*args)
13
- super unless @options.remove_zero.result
13
+ super unless @options.remove_zero.result && !ordinal_number?
14
14
  end
15
15
 
16
16
  include Families::Cyrillic
@@ -70,8 +70,8 @@ module NumbersAndWords
70
70
  nil
71
71
  end
72
72
 
73
- def respond_to_missing?(method_name, include_private: false)
74
- Object.const_get(proxy_class_name(method_name)) || super
73
+ def respond_to_missing?(method_name, include_private = false)
74
+ Object.const_defined?(proxy_class_name(method_name)) || super
75
75
  end
76
76
 
77
77
  private
@@ -43,7 +43,7 @@ module NumbersAndWords
43
43
  end
44
44
 
45
45
  def megs(capacity, options = {})
46
- return t([options[:prefix], :mega, options[:gender]].join('.'))[capacity] if ordinal?(options)
46
+ return scale(t([options[:prefix], :mega, options[:gender]].join('.')), capacity) if ordinal?(options)
47
47
  return super if options[:is_opaque] || options[:is_without_connector]
48
48
 
49
49
  suffix = options[:is_with_comma] ? ',' : " #{union}"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NumbersAndWords
4
- VERSION = '1.1.0'
4
+ VERSION = '1.1.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: numbers_and_words
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Lazarev