Skip to content

Commit

Permalink
Updated changelog and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
shivam091 committed Nov 26, 2023
1 parent 31097ac commit b0ad5f7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## [5.14.0](https://github.com/shivam091/unit_measurements/compare/v5.13.0...v5.14.0) - 2023-11-29

### What's new

- Added `.define_numeric_methods` support to define numeric extension methods for units.

----------

## [5.13.0](https://github.com/shivam091/unit_measurements/compare/v5.12.0...v5.13.0) - 2023-11-27

### What's new
Expand Down
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,31 @@ Length = UnitMeasurements::Length
Volume = UnitMeasurements::Volume
```

## Extras

### Numeric extension methods

The `.define_numeric_methods` method allows you to instantiate measurements in a
manner similar to how `ActiveSupport::Duration` objects are created in Rails,
providing a familiar syntax and functionality.

To define numeric extension methods for specific units within a unit group, use
the following syntax:

```ruby
UnitMeasurements::Length.define_numeric_methods("metre", "foot", "inch")
```

This will enable the usage of these units as methods to instantiate and use measurements:

```ruby
1.m #=> Instantiate a measurement representing 1 metre.
5.feet #=> Instantiate a measurement representing 5 feet.
10.inches #=> Instantiate a measurement representing 10 inches.
1.foot == 12.inches #=> equality comparison between two measurements.
1.ft + 12.in #=> adds quantity of two measurements.
```

## Contributing

1. Fork it
Expand Down

0 comments on commit b0ad5f7

Please sign in to comment.