composite_unit_measurements 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4450805d84ddd3b1cc972d152d187f44cbb1624d87dfece055c6db82ae70d20
4
- data.tar.gz: 621ccd8a46402e7592dd93c8bf0683e414714e3f3fb67f1f4837cceabe96e5ab
3
+ metadata.gz: cd67813e0e00bce4c907e7076ec4a62994570585875da38dfa72bc968b3c0c20
4
+ data.tar.gz: c9de7ccfd6e0ede94d8cd5976174a1a60ed4f4cf3566bc613349a211ea9e4309
5
5
  SHA512:
6
- metadata.gz: 56937734d56198b02eb4c51c9b446558ec31a69bc123489ec371d8f36e7758efda6cf8d50ea85e947e57cf72f003e795a7897d850ff5a228f7505dc53b2aea36
7
- data.tar.gz: d1e8a2129c276a186c8dd8bd7bf4cf5b29e2ff46c9dcff98b6928fba858b5d64441645c905ba273fd82bf547f43d14d1b0b25d2342d2219869d8d0a9b2a4d606
6
+ metadata.gz: 7291bb98bb1e404be485f5f89de9f7594a7093f89cb98c4fd27310051804bfd22ea891acdfffed137ed466b0d9e778d6034439561dffe5e1e5b8b354093044b0
7
+ data.tar.gz: d86f50e73b9044cd8248bf49454c8c036a99b0bd2577fe21554b2c52ff14d1951bf19a11c388b9c0ddfed1670a1d315b054cda0d191909b1ae29cdc8793bf1e9
data/CHANGELOG.md CHANGED
@@ -1,4 +1,14 @@
1
- ## 0.2.0 - 2023-11-17
1
+ ## [0.3.0](https://github.com/shivam091/composite_unit_measurements/compare/v0.2.0...v0.3.0) - 2023-11-27
2
+
3
+ ### What's new
4
+
5
+ - Added ability to parse `kilometre-metre` and `metre-centimetre` length measurements.
6
+ - Added ability to parse `hour-minute` time measurement.
7
+ - Added ability to parse `kilogramme-gramme` weight measurement.
8
+
9
+ -----------
10
+
11
+ ## [0.2.0](https://github.com/shivam091/composite_unit_measurements/compare/v0.1.0...v0.2.0) - 2023-11-17
2
12
 
3
13
  ### What's new
4
14
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- composite_unit_measurements (0.2.0)
4
+ composite_unit_measurements (0.3.0)
5
5
  activesupport (~> 7.0)
6
6
  unit_measurements (~> 5)
7
7
 
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Composite Unit Measurements
2
2
 
3
- A set of specialized parsers for dealing with composite measurement strings.
3
+ A collection of specialized parsers designed for handling composite measurement strings.
4
4
 
5
5
  [![Ruby](https://github.com/shivam091/composite_unit_measurements/actions/workflows/main.yml/badge.svg)](https://github.com/shivam091/composite_unit_measurements/actions/workflows/main.yml)
6
6
  [![Gem Version](https://badge.fury.io/rb/composite_unit_measurements.svg)](https://badge.fury.io/rb/composite_unit_measurements)
@@ -13,17 +13,18 @@ A set of specialized parsers for dealing with composite measurement strings.
13
13
 
14
14
  ## Introduction
15
15
 
16
- The `CompositeUnitMeasurements` gem is a versatile solution tailored for parsing
17
- composite measurement strings. By harnessing the capabilities of the `unit_measurements`
18
- gem, it empowers you to seamlessly handle composite measurements in various units.
16
+ The `CompositeUnitMeasurements` gem offers versatile parsers for efficiently parsing
17
+ composite measurement strings. Leveraging the power of the `unit_measurements` gem,
18
+ it enables smooth handling of composite measurements in various units.
19
19
 
20
20
  ## Minimum Requirements
21
21
 
22
- * Ruby 3.2.2+ (https://www.ruby-lang.org/en/downloads/branches/)
22
+ * Ruby 3.2.2+ ([Download Ruby](https://www.ruby-lang.org/en/downloads/branches/))
23
23
 
24
24
  ## Installation
25
25
 
26
- If using bundler, first add this line to your application's Gemfile:
26
+ To use `composite_unit_measurements-rails` in your Rails application, add the
27
+ following line to your Gemfile:
27
28
 
28
29
  ```ruby
29
30
  gem "composite_unit_measurements"
@@ -44,20 +45,45 @@ You can use an appropriate parser to parse measurements. The final result of `#p
44
45
  is returned in the leftmost unit of your measurement.
45
46
 
46
47
  This gem internally uses [`unit_measurements`](https://github.com/shivam091/unit_measurements)
47
- to perform conversions and arithmetic operations. You can use any
48
- [alias of the units](https://github.com/shivam091/unit_measurements/blob/main/units.md)
49
- to build a supported composite measurements.
48
+ to perform conversions and arithmetic operations. You can build supported composite measurements
49
+ using any [unit alias](https://github.com/shivam091/unit_measurements/blob/main/units.md).
50
+
51
+ ### Examples
52
+
53
+ **Parsing length measurements:**
50
54
 
51
55
  ```ruby
52
- CompositeUnitMeasurements::Length.parse("5 feet 6 inches")
56
+ CompositeUnitMeasurements::Length.parse("5 ft 6 in")
53
57
  #=> 5.5 ft
54
- CompositeUnitMeasurements::Weight.parse("8 pound 12 ounce")
58
+ CompositeUnitMeasurements::Length.parse("6 m 50 cm")
59
+ #=> 6.5 m
60
+ CompositeUnitMeasurements::Length.parse("5 km 500 m")
61
+ #=> 5.5 km
62
+ ```
63
+
64
+ **Parsing weight measurements:**
65
+
66
+ ```ruby
67
+ CompositeUnitMeasurements::Weight.parse("8 lb 12 oz")
55
68
  #=> 8.75 lb
56
- CompositeUnitMeasurements::Time.parse("12:60:60,60")
57
- #=> 13.0166666833333333666667 h
69
+ CompositeUnitMeasurements::Weight.parse("2 st 6 lb")
70
+ #=> 2.428571428571429 st
71
+ CompositeUnitMeasurements::Weight.parse("2 st 6 lb")
72
+ # 4.5 kg
73
+ ```
74
+
75
+ **Parsing time measurements:**
76
+
77
+ ```ruby
78
+ CompositeUnitMeasurements::Time.parse("3 h 45 min")
79
+ #=> 3.75 hx
80
+ CompositeUnitMeasurements::Time.parse("12:60:3600,360000000")
81
+ #=> 14.1 h
58
82
  ```
59
83
 
60
- Each parser has capability to parse `real`, `rational`, `scientific`, and `complex` numbers.
84
+ ### Support for numeric types
85
+
86
+ Each parser can handle various numeric types, including scientific notation, rational numbers, and complex numbers.
61
87
 
62
88
  ```ruby
63
89
  CompositeUnitMeasurements::Length.parse("1+2i ft 12 in")
@@ -74,28 +100,27 @@ CompositeUnitMeasurements::Length.parse("1e-2 ft 1+2i in")
74
100
 
75
101
  ## Packaged parsers & supported composite measurements
76
102
 
77
- There are tons of composite measurements that are bundled with `composite_unit_measurements`.
103
+ The `composite_unit_measurements` gem supports parsing various composite measurements, including:
78
104
 
79
- **1. Unitify::CompositeMeasurements::Length**
105
+ **1. CompositeUnitMeasurements::Length**
80
106
  - foot-inch (5 ft 6 in)
107
+ - metre-centimetre (6 m 50 cm)
108
+ - kilometre-metre (5 km 500 m)
81
109
 
82
- **2. Unitify::CompositeMeasurements::Weight**
110
+ **2. CompositeUnitMeasurements::Weight**
83
111
  - pound-ounce (8 lb 12 oz)
84
112
  - stone-pound (2 st 6 lb)
113
+ - kilogramme-gramme (4 kg 500 g)
85
114
 
86
- **3. Unitify::CompositeMeasurements::Time**
87
- - hour-minute-second-microsecond (12:60:60,60)
115
+ **3. CompositeUnitMeasurements::Time**
116
+ - hour-minute (3 h 45 min)
117
+ - hour-minute-second-microsecond (12:60,3600:360000000)
88
118
 
89
119
  ### Specifing parsers
90
120
 
91
- By default, `composite_unit_measurements` ships with all the packaged parsers and
92
- this happens automatically when you require the gem in the following manner.
93
-
94
- ```ruby
95
- require "composite_unit_measurements"
96
- ```
97
-
98
- You can also use parsers in your application as per your need as:
121
+ By default, `composite_unit_measurements` includes all packaged parsers automatically
122
+ when required in your application. However, you can opt to use specific parsers as
123
+ needed:
99
124
 
100
125
  ```ruby
101
126
  require "composite_unit_measurements/base"
@@ -106,11 +131,13 @@ require "composite_unit_measurements/weight"
106
131
 
107
132
  ## Contributing
108
133
 
109
- 1. Fork it
110
- 2. Create your feature branch (`git checkout -b my-new-feature`)
134
+ Contributions to this project are welcomed! To contribute:
135
+
136
+ 1. Fork this repository
137
+ 2. Create a new branch (`git checkout -b my-new-feature`)
111
138
  3. Commit your changes (`git commit -am "Add some feature"`)
112
- 4. Push to the branch (`git push origin my-new-feature`)
113
- 5. Create new Pull Request
139
+ 4. Push the changes to your branch (`git push origin my-new-feature`)
140
+ 5. Create new **Pull Request**
114
141
 
115
142
  ## License
116
143
 
@@ -17,6 +17,7 @@ module CompositeUnitMeasurements
17
17
  # @param [String] string The string to parse for length measurement.
18
18
  # @return [UnitMeasurements::Length]
19
19
  # Returns a UnitMeasurements::Length object if parsing is successful.
20
+ #
20
21
  # @raise [UnitMeasurements::ParseError]
21
22
  # If the string does not match any known format.
22
23
  #
@@ -24,8 +25,10 @@ module CompositeUnitMeasurements
24
25
  # @since 0.2.0
25
26
  def parse(string)
26
27
  case string
27
- when FOOT_INCH then parse_foot_inch(string)
28
- else raise UnitMeasurements::ParseError, string
28
+ when FOOT_INCH then parse_foot_inch(string)
29
+ when KILOMETRE_METRE then parse_kilometre_metre(string)
30
+ when METRE_CENTIMETRE then parse_metre_centimetre(string)
31
+ else raise UnitMeasurements::ParseError, string
29
32
  end
30
33
  end
31
34
 
@@ -46,7 +49,45 @@ module CompositeUnitMeasurements
46
49
  foot, inch = string.match(FOOT_INCH)&.captures
47
50
 
48
51
  if foot && inch
49
- UnitMeasurements::Length.new(foot, :ft) + UnitMeasurements::Length.new(inch, :in)
52
+ UnitMeasurements::Length.new(foot, "ft") + UnitMeasurements::Length.new(inch, "in")
53
+ end
54
+ end
55
+
56
+ # @private
57
+ # Parses a +string+ representing a length in the format of +metre-centimetre+.
58
+ #
59
+ # @param [String] string
60
+ # The string representing length measurement in the format of *metre-centimetre*.
61
+ # @return [UnitMeasurements::Length]
62
+ # Returns a UnitMeasurements::Length object if parsing is successful.
63
+ #
64
+ # @see METRE_CENTIMETRE
65
+ # @author {Harshal V. Ladhe}[https://shivam091.github.io/]
66
+ # @since 0.3.0
67
+ def parse_metre_centimetre(string)
68
+ metre, centimetre = string.match(METRE_CENTIMETRE)&.captures
69
+
70
+ if metre && centimetre
71
+ UnitMeasurements::Length.new(metre, "m") + UnitMeasurements::Length.new(centimetre, "cm")
72
+ end
73
+ end
74
+
75
+ # @private
76
+ # Parses a +string+ representing a length in the format of +kilometre-metre+.
77
+ #
78
+ # @param [String] string
79
+ # The string representing length measurement in the format of *kilometre-metre*.
80
+ # @return [UnitMeasurements::Length]
81
+ # Returns a UnitMeasurements::Length object if parsing is successful.
82
+ #
83
+ # @see KILOMETRE_METRE
84
+ # @author {Harshal V. Ladhe}[https://shivam091.github.io/]
85
+ # @since 0.3.0
86
+ def parse_kilometre_metre(string)
87
+ kilometre, metre = string.match(KILOMETRE_METRE)&.captures
88
+
89
+ if kilometre && metre
90
+ UnitMeasurements::Length.new(kilometre, "km") + UnitMeasurements::Length.new(metre, "m")
50
91
  end
51
92
  end
52
93
  end
@@ -65,10 +106,40 @@ module CompositeUnitMeasurements
65
106
  # @since 0.2.0
66
107
  INCH_ALIASES = /(?:"|in|inch(?:es)?)/.freeze
67
108
 
109
+ # Regex pattern for aliases of +metre+ unit.
110
+ #
111
+ # @author {Harshal V. Ladhe}[https://shivam091.github.io/]
112
+ # @since 0.3.0
113
+ METRE_ALIASES = /(?:m|meter(?:s)?|metre(?:s)?)/.freeze
114
+
115
+ # Regex pattern for aliases of +centimetre+ unit.
116
+ #
117
+ # @author {Harshal V. Ladhe}[https://shivam091.github.io/]
118
+ # @since 0.3.0
119
+ CENTIMETRE_ALIASES = /(?:cm|centimeter(?:s)?|centimetre(?:s)?)/.freeze
120
+
121
+ # Regex pattern for aliases of +kilometre+ unit.
122
+ #
123
+ # @author {Harshal V. Ladhe}[https://shivam091.github.io/]
124
+ # @since 0.3.0
125
+ KILOMETRE_ALIASES = /(?:km|kilometer(?:s)?|kilometre(?:s)?)/.freeze
126
+
68
127
  # Regex pattern for parsing a length measurement in the format of +foot-inch+.
69
128
  #
70
129
  # @author {Harshal V. Ladhe}[https://shivam091.github.io/]
71
130
  # @since 0.2.0
72
131
  FOOT_INCH = /\A#{ANY_NUMBER}\s*#{FOOT_ALIASES}\s*#{ANY_NUMBER}\s*#{INCH_ALIASES}\z/.freeze
132
+
133
+ # Regex pattern for parsing a length measurement in the format of +metre-centimetre+.
134
+ #
135
+ # @author {Harshal V. Ladhe}[https://shivam091.github.io/]
136
+ # @since 0.3.0
137
+ METRE_CENTIMETRE = /\A#{ANY_NUMBER}\s*#{METRE_ALIASES}\s*#{ANY_NUMBER}\s*#{CENTIMETRE_ALIASES}\z/.freeze
138
+
139
+ # Regex pattern for parsing a length measurement in the format of +kilometre-metre+.
140
+ #
141
+ # @author {Harshal V. Ladhe}[https://shivam091.github.io/]
142
+ # @since 0.3.0
143
+ KILOMETRE_METRE = /\A#{ANY_NUMBER}\s*#{KILOMETRE_ALIASES}\s*#{ANY_NUMBER}\s*#{METRE_ALIASES}\z/.freeze
73
144
  end
74
145
  end
@@ -24,13 +24,33 @@ module CompositeUnitMeasurements
24
24
  # @since 0.2.0
25
25
  def parse(string)
26
26
  case string
27
- when DURATION then parse_duration(string)
28
- else raise UnitMeasurements::ParseError, string
27
+ when HOUR_MINUTE then parse_hour_minute(string)
28
+ when DURATION then parse_duration(string)
29
+ else raise UnitMeasurements::ParseError, string
29
30
  end
30
31
  end
31
32
 
32
33
  private
33
34
 
35
+ # @private
36
+ # Parses a +string+ representing a time in the format of +hour-minute+.
37
+ #
38
+ # @param [String] string
39
+ # The string representing time measurement in the format of *hour-minute*.
40
+ # @return [UnitMeasurements::Time]
41
+ # Returns a UnitMeasurements::Time object if parsing is successful.
42
+ #
43
+ # @see HOUR_MINUTE
44
+ # @author {Harshal V. Ladhe}[https://shivam091.github.io/]
45
+ # @since 0.3.0
46
+ def parse_hour_minute(string)
47
+ hour, minute = string.match(HOUR_MINUTE)&.captures
48
+
49
+ if hour && minute
50
+ UnitMeasurements::Time.new(hour, "h") + UnitMeasurements::Time.new(minute, "min")
51
+ end
52
+ end
53
+
34
54
  # @private
35
55
  # Parses a +string+ representing time duration in the format of
36
56
  # +hour:minute:second,microsecond+ or +hour:minute:second+.
@@ -57,6 +77,24 @@ module CompositeUnitMeasurements
57
77
 
58
78
  private
59
79
 
80
+ # Regex pattern for aliases of +hour+ unit.
81
+ #
82
+ # @author {Harshal V. Ladhe}[https://shivam091.github.io/]
83
+ # @since 0.3.0
84
+ HOUR_ALIASES = /(?:h|hr|hour(?:s)?)/.freeze
85
+
86
+ # Regex pattern for aliases of +minute+ unit.
87
+ #
88
+ # @author {Harshal V. Ladhe}[https://shivam091.github.io/]
89
+ # @since 0.3.0
90
+ MINUTE_ALIASES = /(?:min|minute(?:s)?)/.freeze
91
+
92
+ # Regex pattern for parsing a time measurement in the format of +hour-minute+.
93
+ #
94
+ # @author {Harshal V. Ladhe}[https://shivam091.github.io/]
95
+ # @since 0.3.0
96
+ HOUR_MINUTE = /\A#{ANY_NUMBER}\s*#{HOUR_ALIASES}\s*#{ANY_NUMBER}\s*#{MINUTE_ALIASES}\z/.freeze
97
+
60
98
  # Regex pattern for parsing duration in the format of +hour:minute:second+ or
61
99
  # +hour:minute:second,microsecond+.
62
100
  #
@@ -2,7 +2,28 @@
2
2
  # -*- frozen_string_literal: true -*-
3
3
  # -*- warn_indent: true -*-
4
4
 
5
+ # This module provides parsers and utilities for handling composite unit measurements.
6
+ # It allows parsing and manipulation of various composite measurements for units of
7
+ # +length+, +weight+, +time+ etc.
8
+ #
9
+ # @note
10
+ # This module serves as a namespace for classes and utilities related to composite
11
+ # unit measurements. To parse such measurements, refer to individual classes like
12
+ # {Length}, {Weight}, {Time}, etc. within this module.
13
+ #
14
+ # @example
15
+ # CompositeUnitMeasurements::Length.parse("5 feet 12 inches")
16
+ # => 6.0 ft
17
+ #
18
+ # CompositeUnitMeasurements::Weight.parse("8 lb 12 oz")
19
+ # => 8.75 lb
20
+ #
21
+ # CompositeUnitMeasurements::Time.parse("3 h 45 min")
22
+ # => 3.75 h
23
+ #
24
+ # @author {Harshal V. Ladhe}[https://shivam091.github.io/]
25
+ # @since 0.1.0
5
26
  module CompositeUnitMeasurements
6
27
  # Current stable version
7
- VERSION = "0.2.0"
28
+ VERSION = "0.3.0"
8
29
  end
@@ -24,9 +24,10 @@ module CompositeUnitMeasurements
24
24
  # @since 0.2.0
25
25
  def parse(string)
26
26
  case string
27
- when POUND_OUNCE then parse_pound_ounce(string)
28
- when STONE_POUND then parse_stone_pound(string)
29
- else raise UnitMeasurements::ParseError, string
27
+ when POUND_OUNCE then parse_pound_ounce(string)
28
+ when STONE_POUND then parse_stone_pound(string)
29
+ when KILOGRAMME_GRAMME then parse_kilogramme_gramme(string)
30
+ else raise UnitMeasurements::ParseError, string
30
31
  end
31
32
  end
32
33
 
@@ -47,7 +48,7 @@ module CompositeUnitMeasurements
47
48
  pound, ounce = string.match(POUND_OUNCE)&.captures
48
49
 
49
50
  if pound && ounce
50
- UnitMeasurements::Weight.new(pound, :lb) + UnitMeasurements::Weight.new(ounce, :oz)
51
+ UnitMeasurements::Weight.new(pound, "lb") + UnitMeasurements::Weight.new(ounce, "oz")
51
52
  end
52
53
  end
53
54
 
@@ -66,7 +67,26 @@ module CompositeUnitMeasurements
66
67
  stone, pound = string.match(STONE_POUND)&.captures
67
68
 
68
69
  if stone && pound
69
- UnitMeasurements::Weight.new(stone, :st) + UnitMeasurements::Weight.new(pound, :lb)
70
+ UnitMeasurements::Weight.new(stone, "st") + UnitMeasurements::Weight.new(pound, "lb")
71
+ end
72
+ end
73
+
74
+ # @private
75
+ # Parses a +string+ representing a weight in the format of +kilogramme-gramme+.
76
+ #
77
+ # @param [String] string
78
+ # The string representing weight measurement in the format of *kilogramme-gramme*.
79
+ # @return [UnitMeasurements::Weight]
80
+ # Returns a UnitMeasurements::Weight object if parsing is successful.
81
+ #
82
+ # @see KILOGRAMME_GRAMME
83
+ # @author {Harshal V. Ladhe}[https://shivam091.github.io/]
84
+ # @since 0.3.0
85
+ def parse_kilogramme_gramme(string)
86
+ kilogramme, gramme = string.match(KILOGRAMME_GRAMME)&.captures
87
+
88
+ if kilogramme && gramme
89
+ UnitMeasurements::Weight.new(kilogramme, "kg") + UnitMeasurements::Weight.new(gramme, "g")
70
90
  end
71
91
  end
72
92
  end
@@ -77,30 +97,48 @@ module CompositeUnitMeasurements
77
97
  #
78
98
  # @author {Harshal V. Ladhe}[https://shivam091.github.io/]
79
99
  # @since 0.2.0
80
- POUND_UNITS = /(?:#|lb|lbs|lbm|pound-mass|pound(?:s)?)/.freeze
100
+ POUND_ALIASES = /(?:#|lb|lbs|lbm|pound-mass|pound(?:s)?)/.freeze
81
101
 
82
102
  # Regex pattern for aliases of +ounce+ unit.
83
103
  #
84
104
  # @author {Harshal V. Ladhe}[https://shivam091.github.io/]
85
105
  # @since 0.2.0
86
- OUNCE_UNITS = /(?:oz|ounce(?:s)?)/.freeze
106
+ OUNCE_ALIASES = /(?:oz|ounce(?:s)?)/.freeze
87
107
 
88
108
  # Regex pattern for aliases of +stone+ unit.
89
109
  #
90
110
  # @author {Harshal V. Ladhe}[https://shivam091.github.io/]
91
111
  # @since 0.2.0
92
- STONE_UNITS = /(?:st|stone(?:s)?)/.freeze
112
+ STONE_ALIASES = /(?:st|stone(?:s)?)/.freeze
113
+
114
+ # Regex pattern for aliases of +gramme+ unit.
115
+ #
116
+ # @author {Harshal V. Ladhe}[https://shivam091.github.io/]
117
+ # @since 0.3.0
118
+ GRAMME_ALIASES = /(?:g|gram(?:s)?|gramme(?:s)?)/.freeze
119
+
120
+ # Regex pattern for aliases of +kilogramme+ unit.
121
+ #
122
+ # @author {Harshal V. Ladhe}[https://shivam091.github.io/]
123
+ # @since 0.3.0
124
+ KILOGRAMME_ALIASES = /(?:kg|kilogram(?:s)?|kilogramme(?:s)?)/.freeze
93
125
 
94
126
  # Regex pattern for parsing a weight measurement in the format of +pound-ounce+.
95
127
  #
96
128
  # @author {Harshal V. Ladhe}[https://shivam091.github.io/]
97
129
  # @since 0.2.0
98
- POUND_OUNCE = /\A#{ANY_NUMBER}\s*#{POUND_UNITS}\s*#{ANY_NUMBER}\s*#{OUNCE_UNITS}\z/.freeze
130
+ POUND_OUNCE = /\A#{ANY_NUMBER}\s*#{POUND_ALIASES}\s*#{ANY_NUMBER}\s*#{OUNCE_ALIASES}\z/.freeze
99
131
 
100
132
  # Regex pattern for parsing a weight measurement in the format of +stone-pound+.
101
133
  #
102
134
  # @author {Harshal V. Ladhe}[https://shivam091.github.io/]
103
135
  # @since 0.2.0
104
- STONE_POUND = /\A#{ANY_NUMBER}\s*#{STONE_UNITS}\s*#{ANY_NUMBER}\s*#{POUND_UNITS}\z/.freeze
136
+ STONE_POUND = /\A#{ANY_NUMBER}\s*#{STONE_ALIASES}\s*#{ANY_NUMBER}\s*#{POUND_ALIASES}\z/.freeze
137
+
138
+ # Regex pattern for parsing a weight measurement in the format of +kilogramme-gramme+.
139
+ #
140
+ # @author {Harshal V. Ladhe}[https://shivam091.github.io/]
141
+ # @since 0.3.0
142
+ KILOGRAMME_GRAMME = /\A#{ANY_NUMBER}\s*#{KILOGRAMME_ALIASES}\s*#{ANY_NUMBER}\s*#{GRAMME_ALIASES}\z/.freeze
105
143
  end
106
144
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: composite_unit_measurements
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harshal LADHE
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-17 00:00:00.000000000 Z
11
+ date: 2023-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport