https://github.com/jgraichen/uuid4
UUID support library.
https://github.com/jgraichen/uuid4
Last synced: 4 months ago
JSON representation
UUID support library.
- Host: GitHub
- URL: https://github.com/jgraichen/uuid4
- Owner: jgraichen
- License: mit
- Created: 2016-05-31T19:56:49.000Z (about 10 years ago)
- Default Branch: main
- Last Pushed: 2025-12-31T14:47:54.000Z (6 months ago)
- Last Synced: 2026-01-04T17:01:22.734Z (6 months ago)
- Language: Ruby
- Size: 76.2 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# UUID4
[](https://travis-ci.org/jgraichen/uuid4) [](https://gemnasium.com/github.com/jgraichen/uuid4) [](https://rubygems.org/gems/uuid4) [](https://github.com/jgraichen/uuid4/blob/master/LICENSE.txt)
A UUID support library specialized on v4 UUIDs, parsing and formatting existing UUIDs. It can encode and decode dashed UUIDs, compact UUIDs, large integers, UUID URNs and Base62 coded UUIDs.
## Installation
```ruby
gem 'uuid4'
```
And then execute:
$ bundle
Or install it yourself as:
$ gem install uuid4
## Usage
```ruby
uuid = UUID4('d40aa316-6e30-4bae-a673-7b2cf35a8f99')
# =>
uuid.to_s
# => "d40aa316-6e30-4bae-a673-7b2cf35a8f99"
uuid.to_s(format: :compact)
# => "d40aa3166e304baea6737b2cf35a8f99"
uuid.to_s(format: :base62)
# => "6s7exj9M9mGqLs5KhhWWaB"
uuid.to_s(format: :urn)
# => "urn:uuid:d40aa316-6e30-4bae-a673-7b2cf35a8f99"
uuid.to_i
# => 281851565884874220786890141677225938841
uuid == 'd40aa316-6e30-4bae-a673-7b2cf35a8f99'
# => true
'd40aa316-6e30-4bae-a673-7b2cf35a8f99' == uuid
# => true
uuid == "d40aa3166e304baea6737b2cf35a8f99"
# => true
uuid == '6s7exj9M9mGqLs5KhhWWaB'
# => true
uuid == 281851565884874220786890141677225938841
# => true
uuid == 'urn:uuid:d40aa316-6e30-4bae-a673-7b2cf35a8f99'
# => true
uuid == UUID4('d40aa316-6e30-4bae-a673-7b2cf35a8f99')
# => true
```
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/jgraichen/uuid4.
## License
(c) Jan Graichen
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).