composite_unit_measurements 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +1 -1
- data/README.md +27 -33
- data/lib/composite_unit_measurements/base.rb +3 -0
- data/lib/composite_unit_measurements/length.rb +16 -5
- data/lib/composite_unit_measurements/time.rb +12 -4
- data/lib/composite_unit_measurements/version.rb +1 -1
- data/lib/composite_unit_measurements/volume.rb +79 -0
- data/lib/composite_unit_measurements/weight.rb +17 -6
- data/lib/composite_unit_measurements.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c25131e598e9fb02e3b569eeb45df0f39b254d5d85ab7e60ee729365b70c59cc
|
4
|
+
data.tar.gz: c659dea44b220217466355182589a808a098d1d654efbc664f55e6556198422f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca73e1e52c1c40b08f95ce7196bdb5c290dbe4d955c8c9c80affc6210b5657cb05a013e5352467412a8139cb1ef927914b96cd59843565fb30462ba4ce77419f
|
7
|
+
data.tar.gz: 7528d84b11c1eeb86eea5b5683e581513695b816662669711fa8a567a9fba1c7b4f505d19dd250c6b1175c5e9bdea896f5f483e0096c35b38a591aa7477124fa
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## [0.4.0](https://github.com/shivam091/composite_unit_measurements/compare/v0.2.0...v0.3.0) - 2023-11-30
|
2
|
+
|
3
|
+
### What's new
|
4
|
+
|
5
|
+
- Added ability to parse `litre-millilitre` volume measurements.
|
6
|
+
- Updated readme with parsing examples.
|
7
|
+
|
8
|
+
-----------
|
9
|
+
|
1
10
|
## [0.3.0](https://github.com/shivam091/composite_unit_measurements/compare/v0.2.0...v0.3.0) - 2023-11-27
|
2
11
|
|
3
12
|
### What's new
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -13,7 +13,7 @@ A collection of specialized parsers designed for handling composite measurement
|
|
13
13
|
|
14
14
|
## Introduction
|
15
15
|
|
16
|
-
The `
|
16
|
+
The `composite_unit_measurements` gem offers versatile parsers for efficiently parsing
|
17
17
|
composite measurement strings. Leveraging the power of the `unit_measurements` gem,
|
18
18
|
it enables smooth handling of composite measurements in various units.
|
19
19
|
|
@@ -23,7 +23,7 @@ it enables smooth handling of composite measurements in various units.
|
|
23
23
|
|
24
24
|
## Installation
|
25
25
|
|
26
|
-
To use `composite_unit_measurements
|
26
|
+
To use `composite_unit_measurements` in your Rails application, add the
|
27
27
|
following line to your Gemfile:
|
28
28
|
|
29
29
|
```ruby
|
@@ -40,10 +40,13 @@ Or otherwise simply install it yourself as:
|
|
40
40
|
|
41
41
|
## Usage
|
42
42
|
|
43
|
-
Each packaged parser includes the
|
44
|
-
You can use an appropriate parser to
|
43
|
+
Each packaged parser includes the `.parse` method to parse composite measurements.
|
44
|
+
You can use an appropriate parser to these measurements and the final result of
|
45
45
|
is returned in the leftmost unit of your measurement.
|
46
46
|
|
47
|
+
The result of each parser method returns an instance of measurement on which we can
|
48
|
+
perform any functionality offered by `unit_measurements`.
|
49
|
+
|
47
50
|
This gem internally uses [`unit_measurements`](https://github.com/shivam091/unit_measurements)
|
48
51
|
to perform conversions and arithmetic operations. You can build supported composite measurements
|
49
52
|
using any [unit alias](https://github.com/shivam091/unit_measurements/blob/main/units.md).
|
@@ -53,32 +56,25 @@ using any [unit alias](https://github.com/shivam091/unit_measurements/blob/main/
|
|
53
56
|
**Parsing length measurements:**
|
54
57
|
|
55
58
|
```ruby
|
56
|
-
CompositeUnitMeasurements::Length.parse("5
|
57
|
-
#=> 5.5 ft
|
58
|
-
CompositeUnitMeasurements::Length.parse("6 m 50 cm")
|
59
|
-
#=> 6.5 m
|
60
|
-
CompositeUnitMeasurements::Length.parse("5 km 500 m")
|
61
|
-
#=> 5.5 km
|
59
|
+
CompositeUnitMeasurements::Length.parse("5 km 500 m") #=> 5.5 km
|
62
60
|
```
|
63
61
|
|
64
62
|
**Parsing weight measurements:**
|
65
63
|
|
66
64
|
```ruby
|
67
|
-
CompositeUnitMeasurements::Weight.parse("
|
68
|
-
#=> 8.75 lb
|
69
|
-
CompositeUnitMeasurements::Weight.parse("2 st 6 lb")
|
70
|
-
#=> 2.428571428571429 st
|
71
|
-
CompositeUnitMeasurements::Weight.parse("2 st 6 lb")
|
72
|
-
# 4.5 kg
|
65
|
+
CompositeUnitMeasurements::Weight.parse("4 kg 500 g") # 4.5 kg
|
73
66
|
```
|
74
67
|
|
75
68
|
**Parsing time measurements:**
|
76
69
|
|
77
70
|
```ruby
|
78
|
-
CompositeUnitMeasurements::Time.parse("3 h 45 min")
|
79
|
-
|
80
|
-
|
81
|
-
|
71
|
+
CompositeUnitMeasurements::Time.parse("3 h 45 min") #=> 3.75 hr
|
72
|
+
```
|
73
|
+
|
74
|
+
**Parsing volume measurements:**
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
CompositeUnitMeasurements::Volume.parse("2 l 250 ml") #=> 2.25 l
|
82
78
|
```
|
83
79
|
|
84
80
|
### Support for numeric types
|
@@ -86,16 +82,11 @@ CompositeUnitMeasurements::Time.parse("12:60:3600,360000000")
|
|
86
82
|
Each parser can handle various numeric types, including scientific notation, rational numbers, and complex numbers.
|
87
83
|
|
88
84
|
```ruby
|
89
|
-
CompositeUnitMeasurements::Length.parse("1+2i ft 12 in")
|
90
|
-
#=>
|
91
|
-
CompositeUnitMeasurements::Length.parse("1
|
92
|
-
#=>
|
93
|
-
CompositeUnitMeasurements::Length.parse("
|
94
|
-
#=> 1.5833333333333333+0.16666666666666669i ft
|
95
|
-
CompositeUnitMeasurements::Length.parse("2 ft 1+2i in")
|
96
|
-
#=> 2.0833333333333335+0.16666666666666669i ft
|
97
|
-
CompositeUnitMeasurements::Length.parse("1e-2 ft 1+2i in")
|
98
|
-
#=> 0.09333333333333334+0.16666666666666669i ft
|
85
|
+
CompositeUnitMeasurements::Length.parse("1+2i ft 12 in") #=> 2.0+2.0i ft
|
86
|
+
CompositeUnitMeasurements::Length.parse("1.5 ft 12e2 in") #=> 101.5 ft
|
87
|
+
CompositeUnitMeasurements::Length.parse("1 1/2 ft 1+2i in") #=> 1.5833333333333333+0.16666666666666669i ft
|
88
|
+
CompositeUnitMeasurements::Length.parse("2 ft 1+2i in") #=> 2.0833333333333335+0.16666666666666669i ft
|
89
|
+
CompositeUnitMeasurements::Length.parse("1e-2 ft 1+2i in") #=> 0.09333333333333334+0.16666666666666669i ft
|
99
90
|
```
|
100
91
|
|
101
92
|
## Packaged parsers & supported composite measurements
|
@@ -103,19 +94,22 @@ CompositeUnitMeasurements::Length.parse("1e-2 ft 1+2i in")
|
|
103
94
|
The `composite_unit_measurements` gem supports parsing various composite measurements, including:
|
104
95
|
|
105
96
|
**1. CompositeUnitMeasurements::Length**
|
106
|
-
- foot-inch (5 ft 6 in)
|
107
97
|
- metre-centimetre (6 m 50 cm)
|
108
98
|
- kilometre-metre (5 km 500 m)
|
99
|
+
- foot-inch (5 ft 6 in)
|
109
100
|
|
110
101
|
**2. CompositeUnitMeasurements::Weight**
|
102
|
+
- kilogramme-gramme (4 kg 500 g)
|
111
103
|
- pound-ounce (8 lb 12 oz)
|
112
104
|
- stone-pound (2 st 6 lb)
|
113
|
-
- kilogramme-gramme (4 kg 500 g)
|
114
105
|
|
115
106
|
**3. CompositeUnitMeasurements::Time**
|
116
107
|
- hour-minute (3 h 45 min)
|
117
108
|
- hour-minute-second-microsecond (12:60,3600:360000000)
|
118
109
|
|
110
|
+
**4. CompositeUnitMeasurements::Volume**
|
111
|
+
- litre-millilitre (2 l 250 ml)
|
112
|
+
|
119
113
|
### Specifing parsers
|
120
114
|
|
121
115
|
By default, `composite_unit_measurements` includes all packaged parsers automatically
|
@@ -141,4 +135,4 @@ Contributions to this project are welcomed! To contribute:
|
|
141
135
|
|
142
136
|
## License
|
143
137
|
|
144
|
-
Copyright 2023 [Harshal V. LADHE](
|
138
|
+
Copyright 2023 [Harshal V. LADHE](https://shivam091.github.io), Released under the [MIT License](http://opensource.org/licenses/MIT).
|
@@ -54,4 +54,7 @@ module CompositeUnitMeasurements
|
|
54
54
|
|
55
55
|
# Matches any number, including scientific, complex, rational, and real numbers.
|
56
56
|
ANY_NUMBER = /(?<number>#{SCIENTIFIC_NUMBER}|#{COMPLEX_NUMBER}|#{RATIONAL_NUMBER}|#{REAL_NUMBER})/.freeze
|
57
|
+
|
58
|
+
private_constant :REAL_NUMBER, :RATIONAL_NUMBER, :SCIENTIFIC_NUMBER, :COMPLEX_NUMBER,
|
59
|
+
:ANY_NUMBER
|
57
60
|
end
|
@@ -14,6 +14,13 @@ module CompositeUnitMeasurements
|
|
14
14
|
class << self
|
15
15
|
# Parses a given +string+ into a +UnitMeasurements::Length+ object.
|
16
16
|
#
|
17
|
+
# @example Parse 'metre-centimetre' measurement:
|
18
|
+
# CompositeUnitMeasurements::Length.parse("6 m 50 cm") #=> 6.5 m
|
19
|
+
# @example Parse 'kilometre-metre' measurement:
|
20
|
+
# CompositeUnitMeasurements::Length.parse("5 km 500 m") #=> 5.5 km
|
21
|
+
# @example Parse 'foot-inch' measurement:
|
22
|
+
# CompositeUnitMeasurements::Length.parse("5 ft 6 in") #=> 5.5 ft
|
23
|
+
#
|
17
24
|
# @param [String] string The string to parse for length measurement.
|
18
25
|
# @return [UnitMeasurements::Length]
|
19
26
|
# Returns a UnitMeasurements::Length object if parsing is successful.
|
@@ -35,7 +42,8 @@ module CompositeUnitMeasurements
|
|
35
42
|
private
|
36
43
|
|
37
44
|
# @private
|
38
|
-
# Parses a +string+ representing a length in the format of +foot-inch
|
45
|
+
# Parses a +string+ representing a length in the format of +foot-inch+
|
46
|
+
# into a +UnitMeasurements::Length+ object.
|
39
47
|
#
|
40
48
|
# @param [String] string
|
41
49
|
# The string representing length measurement in the format of *foot-inch*.
|
@@ -54,7 +62,8 @@ module CompositeUnitMeasurements
|
|
54
62
|
end
|
55
63
|
|
56
64
|
# @private
|
57
|
-
# Parses a +string+ representing a length in the format of +metre-centimetre
|
65
|
+
# Parses a +string+ representing a length in the format of +metre-centimetre+
|
66
|
+
# into a +UnitMeasurements::Length+ object.
|
58
67
|
#
|
59
68
|
# @param [String] string
|
60
69
|
# The string representing length measurement in the format of *metre-centimetre*.
|
@@ -73,7 +82,8 @@ module CompositeUnitMeasurements
|
|
73
82
|
end
|
74
83
|
|
75
84
|
# @private
|
76
|
-
# Parses a +string+ representing a length in the format of +kilometre-metre
|
85
|
+
# Parses a +string+ representing a length in the format of +kilometre-metre+
|
86
|
+
# into a +UnitMeasurements::Length+ object.
|
77
87
|
#
|
78
88
|
# @param [String] string
|
79
89
|
# The string representing length measurement in the format of *kilometre-metre*.
|
@@ -92,8 +102,6 @@ module CompositeUnitMeasurements
|
|
92
102
|
end
|
93
103
|
end
|
94
104
|
|
95
|
-
private
|
96
|
-
|
97
105
|
# Regex pattern for aliases of +foot+ unit.
|
98
106
|
#
|
99
107
|
# @author {Harshal V. Ladhe}[https://shivam091.github.io/]
|
@@ -141,5 +149,8 @@ module CompositeUnitMeasurements
|
|
141
149
|
# @author {Harshal V. Ladhe}[https://shivam091.github.io/]
|
142
150
|
# @since 0.3.0
|
143
151
|
KILOMETRE_METRE = /\A#{ANY_NUMBER}\s*#{KILOMETRE_ALIASES}\s*#{ANY_NUMBER}\s*#{METRE_ALIASES}\z/.freeze
|
152
|
+
|
153
|
+
private_constant :FOOT_ALIASES, :INCH_ALIASES, :METRE_ALIASES, :CENTIMETRE_ALIASES,
|
154
|
+
:KILOMETRE_ALIASES, :FOOT_INCH, :KILOMETRE_METRE, :METRE_CENTIMETRE
|
144
155
|
end
|
145
156
|
end
|
@@ -14,6 +14,12 @@ module CompositeUnitMeasurements
|
|
14
14
|
class << self
|
15
15
|
# Parses a given +string+ into a +UnitMeasurements::Time+ object.
|
16
16
|
#
|
17
|
+
# @example Parse 'hour-minute' measurement:
|
18
|
+
# CompositeUnitMeasurements::Time.parse("3 h 45 min") #=> 3.75 h
|
19
|
+
# @example Parse 'duration':
|
20
|
+
# CompositeUnitMeasurements::Time.parse("12:60:3600,360000000") #=> 14.1 h
|
21
|
+
# CompositeUnitMeasurements::Time.parse("12:60:3600") #=> 14.0 h
|
22
|
+
#
|
17
23
|
# @param [String] string The string to parse for time measurement.
|
18
24
|
# @return [UnitMeasurements::Time]
|
19
25
|
# Returns a UnitMeasurements::Time object if parsing is successful.
|
@@ -33,7 +39,8 @@ module CompositeUnitMeasurements
|
|
33
39
|
private
|
34
40
|
|
35
41
|
# @private
|
36
|
-
# Parses a +string+ representing a time in the format of +hour-minute
|
42
|
+
# Parses a +string+ representing a time in the format of +hour-minute+
|
43
|
+
# into a +UnitMeasurements::Time+ object.
|
37
44
|
#
|
38
45
|
# @param [String] string
|
39
46
|
# The string representing time measurement in the format of *hour-minute*.
|
@@ -53,7 +60,8 @@ module CompositeUnitMeasurements
|
|
53
60
|
|
54
61
|
# @private
|
55
62
|
# Parses a +string+ representing time duration in the format of
|
56
|
-
# +hour:minute:second,microsecond+ or +hour:minute:second
|
63
|
+
# +hour:minute:second,microsecond+ or +hour:minute:second+ into a
|
64
|
+
# +UnitMeasurements::Time+ object.
|
57
65
|
#
|
58
66
|
# @param [String] string The string representing time duration.
|
59
67
|
# @return [UnitMeasurements::Time]
|
@@ -75,8 +83,6 @@ module CompositeUnitMeasurements
|
|
75
83
|
end
|
76
84
|
end
|
77
85
|
|
78
|
-
private
|
79
|
-
|
80
86
|
# Regex pattern for aliases of +hour+ unit.
|
81
87
|
#
|
82
88
|
# @author {Harshal V. Ladhe}[https://shivam091.github.io/]
|
@@ -101,5 +107,7 @@ module CompositeUnitMeasurements
|
|
101
107
|
# @author {Harshal V. Ladhe}[https://shivam091.github.io/]
|
102
108
|
# @since 0.2.0
|
103
109
|
DURATION = /\A(?<hour>#{REAL_NUMBER}):(?<min>#{REAL_NUMBER}):(?:(?<sec>#{REAL_NUMBER}))?(?:,(?<msec>#{REAL_NUMBER}))?\z/.freeze
|
110
|
+
|
111
|
+
private_constant :HOUR_ALIASES, :MINUTE_ALIASES, :HOUR_MINUTE, :DURATION
|
104
112
|
end
|
105
113
|
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# -*- frozen_string_literal: true -*-
|
3
|
+
# -*- warn_indent: true -*-
|
4
|
+
|
5
|
+
require "unit_measurements/unit_groups/volume"
|
6
|
+
|
7
|
+
module CompositeUnitMeasurements
|
8
|
+
# A parser handling +volume+ measurements, particularly for composite units
|
9
|
+
# like +litre-millilitre+, +gallon-quart+, +quart-pint+, etc.
|
10
|
+
#
|
11
|
+
# @author {Harshal V. Ladhe}[https://shivam091.github.io/]
|
12
|
+
# @since 0.4.0
|
13
|
+
class Volume
|
14
|
+
class << self
|
15
|
+
# Parses a given +string+ into a +UnitMeasurements::Volume+ object.
|
16
|
+
#
|
17
|
+
# @example Parse 'litre-millilitre' measurement:
|
18
|
+
# CompositeUnitMeasurements::Volume.parse("2 l 250 ml") #=> 2.25 l
|
19
|
+
#
|
20
|
+
# @param [String] string The string to parse for volume measurement.
|
21
|
+
# @return [UnitMeasurements::Volume]
|
22
|
+
# Returns a UnitMeasurements::Volume object if parsing is successful.
|
23
|
+
#
|
24
|
+
# @raise [UnitMeasurements::ParseError]
|
25
|
+
# If the string does not match any known format.
|
26
|
+
#
|
27
|
+
# @author {Harshal V. Ladhe}[https://shivam091.github.io/]
|
28
|
+
# @since 0.4.0
|
29
|
+
def parse(string)
|
30
|
+
case string
|
31
|
+
when LITRE_MILLILITRE then parse_litre_millilitre(string)
|
32
|
+
else raise UnitMeasurements::ParseError, string
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
# @private
|
39
|
+
# Parses a +string+ representing a volume in the format of +litre-millilitre+
|
40
|
+
# into a +UnitMeasurements::Volume+ object.
|
41
|
+
#
|
42
|
+
# @param [String] string
|
43
|
+
# The string representing volume measurement in the format of *litre-millilitre*.
|
44
|
+
# @return [UnitMeasurements::Volume]
|
45
|
+
# Returns a UnitMeasurements::Volume object if parsing is successful.
|
46
|
+
#
|
47
|
+
# @see LITRE_MILLILITRE
|
48
|
+
# @author {Harshal V. Ladhe}[https://shivam091.github.io/]
|
49
|
+
# @since 0.4.0
|
50
|
+
def parse_litre_millilitre(string)
|
51
|
+
litre, millilitre = string.match(LITRE_MILLILITRE)&.captures
|
52
|
+
|
53
|
+
if litre && millilitre
|
54
|
+
UnitMeasurements::Volume.new(litre, "l") + UnitMeasurements::Volume.new(millilitre, "ml")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Regex pattern for aliases of +litre+ unit.
|
60
|
+
#
|
61
|
+
# @author {Harshal V. Ladhe}[https://shivam091.github.io/]
|
62
|
+
# @since 0.4.0
|
63
|
+
LITRE_ALIASES = /(?:l|L|liter(?:s)?|litre(?:s)?)/.freeze
|
64
|
+
|
65
|
+
# Regex pattern for aliases of +millilitre+ unit.
|
66
|
+
#
|
67
|
+
# @author {Harshal V. Ladhe}[https://shivam091.github.io/]
|
68
|
+
# @since 0.4.0
|
69
|
+
MILLILITRE_ALIASES = /(?:ml|mL|milliliter(?:s)?|millilitre(?:s)?)/.freeze
|
70
|
+
|
71
|
+
# Regex pattern for parsing a volume measurement in the format of +litre-millilitre+.
|
72
|
+
#
|
73
|
+
# @author {Harshal V. Ladhe}[https://shivam091.github.io/]
|
74
|
+
# @since 0.4.0
|
75
|
+
LITRE_MILLILITRE = /\A#{ANY_NUMBER}\s*#{LITRE_ALIASES}\s*#{ANY_NUMBER}\s*#{MILLILITRE_ALIASES}\z/.freeze
|
76
|
+
|
77
|
+
private_constant :LITRE_MILLILITRE, :LITRE_ALIASES, :MILLILITRE_ALIASES
|
78
|
+
end
|
79
|
+
end
|
@@ -6,7 +6,7 @@ require "unit_measurements/unit_groups/weight"
|
|
6
6
|
|
7
7
|
module CompositeUnitMeasurements
|
8
8
|
# A parser handling +weight+ measurements, particularly for composite units
|
9
|
-
# like +pound-ounce+, +stone-pound
|
9
|
+
# like +kilogramme-gramme+, +pound-ounce+, +stone-pound+ etc.
|
10
10
|
#
|
11
11
|
# @author {Harshal V. Ladhe}[https://shivam091.github.io/]
|
12
12
|
# @since 0.2.0
|
@@ -14,6 +14,13 @@ module CompositeUnitMeasurements
|
|
14
14
|
class << self
|
15
15
|
# Parses a given +string+ into a +UnitMeasurements::Weight+ object.
|
16
16
|
#
|
17
|
+
# @example Parse 'kilogramme-gramme' measurement:
|
18
|
+
# CompositeUnitMeasurements::Weight.parse("4 kg 500 g") #=> 4.5 kg
|
19
|
+
# @example Parse 'pound-ounce' measurement:
|
20
|
+
# CompositeUnitMeasurements::Weight.parse("8 lb 12 oz") #=> 8.75 lb
|
21
|
+
# @example Parse 'stone-pound' measurement:
|
22
|
+
# CompositeUnitMeasurements::Weight.parse("2 st 6 lb") #=> 2.428571428571429 st
|
23
|
+
#
|
17
24
|
# @param [String] string The string to parse for weight measurement.
|
18
25
|
# @return [UnitMeasurements::Weight]
|
19
26
|
# Returns a UnitMeasurements::Weight object if parsing is successful.
|
@@ -34,7 +41,8 @@ module CompositeUnitMeasurements
|
|
34
41
|
private
|
35
42
|
|
36
43
|
# @private
|
37
|
-
# Parses a +string+ representing a weight in the format of +pound-ounce
|
44
|
+
# Parses a +string+ representing a weight in the format of +pound-ounce+
|
45
|
+
# into a +UnitMeasurements::Weight+ object.
|
38
46
|
#
|
39
47
|
# @param [String] string
|
40
48
|
# The string representing weight measurement in the format of *pound-ounce*.
|
@@ -53,7 +61,8 @@ module CompositeUnitMeasurements
|
|
53
61
|
end
|
54
62
|
|
55
63
|
# @private
|
56
|
-
# Parses a +string+ representing a weight in the format of +stone-pound
|
64
|
+
# Parses a +string+ representing a weight in the format of +stone-pound+
|
65
|
+
# into a +UnitMeasurements::Weight+ object.
|
57
66
|
#
|
58
67
|
# @param [String] string
|
59
68
|
# The string representing weight measurement in the format of *stone-pound*.
|
@@ -72,7 +81,8 @@ module CompositeUnitMeasurements
|
|
72
81
|
end
|
73
82
|
|
74
83
|
# @private
|
75
|
-
# Parses a +string+ representing a weight in the format of +kilogramme-gramme
|
84
|
+
# Parses a +string+ representing a weight in the format of +kilogramme-gramme+
|
85
|
+
# into a +UnitMeasurements::Weight+ object.
|
76
86
|
#
|
77
87
|
# @param [String] string
|
78
88
|
# The string representing weight measurement in the format of *kilogramme-gramme*.
|
@@ -91,8 +101,6 @@ module CompositeUnitMeasurements
|
|
91
101
|
end
|
92
102
|
end
|
93
103
|
|
94
|
-
private
|
95
|
-
|
96
104
|
# Regex pattern for aliases of +pound+ unit.
|
97
105
|
#
|
98
106
|
# @author {Harshal V. Ladhe}[https://shivam091.github.io/]
|
@@ -140,5 +148,8 @@ module CompositeUnitMeasurements
|
|
140
148
|
# @author {Harshal V. Ladhe}[https://shivam091.github.io/]
|
141
149
|
# @since 0.3.0
|
142
150
|
KILOGRAMME_GRAMME = /\A#{ANY_NUMBER}\s*#{KILOGRAMME_ALIASES}\s*#{ANY_NUMBER}\s*#{GRAMME_ALIASES}\z/.freeze
|
151
|
+
|
152
|
+
private_constant :KILOGRAMME_GRAMME, :POUND_ALIASES, :OUNCE_ALIASES, :STONE_ALIASES ,
|
153
|
+
:GRAMME_ALIASES, :KILOGRAMME_ALIASES, :POUND_OUNCE, :STONE_POUND
|
143
154
|
end
|
144
155
|
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.
|
4
|
+
version: 0.4.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
|
+
date: 2023-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -124,6 +124,7 @@ files:
|
|
124
124
|
- lib/composite_unit_measurements/length.rb
|
125
125
|
- lib/composite_unit_measurements/time.rb
|
126
126
|
- lib/composite_unit_measurements/version.rb
|
127
|
+
- lib/composite_unit_measurements/volume.rb
|
127
128
|
- lib/composite_unit_measurements/weight.rb
|
128
129
|
homepage: https://github.com/shivam091/composite_unit_measurements
|
129
130
|
licenses:
|