Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tanvir002700/convert_unit
A Ruby Library for dealing with different types of unit conversion.
https://github.com/tanvir002700/convert_unit
conversion ruby ruby-gem unit-conversion
Last synced: about 1 month ago
JSON representation
A Ruby Library for dealing with different types of unit conversion.
- Host: GitHub
- URL: https://github.com/tanvir002700/convert_unit
- Owner: tanvir002700
- License: mit
- Created: 2017-12-21T12:27:19.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-29T16:09:29.000Z (almost 7 years ago)
- Last Synced: 2024-04-26T00:26:00.202Z (8 months ago)
- Topics: conversion, ruby, ruby-gem, unit-conversion
- Language: Ruby
- Homepage: https://rubygems.org/gems/convert_unit
- Size: 193 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# ConvertUnit
[![Build Status](https://travis-ci.org/tanvir002700/convert_unit.svg?branch=master)](https://travis-ci.org/tanvir002700/convert_unit)
[![Coverage Status](https://coveralls.io/repos/github/tanvir002700/convert_unit/badge.svg?branch=master)](https://coveralls.io/github/tanvir002700/convert_unit?branch=master)
[![Maintainability](https://api.codeclimate.com/v1/badges/6e3e7ff7c7b040d1680d/maintainability)](https://codeclimate.com/github/tanvir002700/convert_unit/maintainability)
[![Gem Version](https://badge.fury.io/rb/convert_unit.svg)](https://rubygems.org/gems/convert_unit)
[![Downloads](https://img.shields.io/gem/dt/convert_unit.svg)](https://rubygems.org/gems/convert_unit)
[![GitHub last commit (branch)](https://img.shields.io/github/last-commit/tanvir002700/convert_unit/master.svg)](https://github.com/tanvir002700/convert_unit)
[![license](https://img.shields.io/github/license/tanvir002700/convert_unit.svg)](https://github.com/tanvir002700/convert_unit/blob/master/LICENSE)## Introduction
A Ruby Library for dealing with different types of unit conversion.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'convert_unit'
```And then execute:
$ bundle
Or install it yourself as:
$ gem install convert_unit
## Usage
```ruby
require 'convert_unit'meter = ConvertUnit::Length.new(1, 'km')
meter.to('km') #=> ConvertUnit::Length.new(1000, 'm')# Comparisons
ConvertUnit::Length.new(1, 'km') == ConvertUnit::Length.new(1000, 'm') #=> true
ConvertUnit::Length.new(1, 'km') == ConvertUnit::Length.new(1, 'm') #=> falseConvertUnit::Length.new(1, 'km') === ConvertUnit::Length.new(1, 'km') #=> true
ConvertUnit::Length.new(1, 'km') === ConvertUnit::Length.new(1000, 'm') #=> false# Arithmetic
ConvertUnit::Length.new(1, 'km') + ConvertUnit::Length.new(1, 'km') == ConvertUnit::Length.new(2, 'km')
ConvertUnit::Length.new(1, 'km') + ConvertUnit::Length.new(1000, 'm') == ConvertUnit::Length.new(2, 'km')
ConvertUnit::Length.new(1000, 'm') + ConvertUnit::Length.new(1, 'km') == ConvertUnit::Length.new(2000, 'm')
ConvertUnit::Length.new(1000, 'm') - ConvertUnit::Length.new(1, 'km') == ConvertUnit::Length.new(0, 'm')# Valid units argument list
ConvertUnit::Length::UNITS_SYMBOL #=> { "millimeter"=>"mm", "centimeter"=>"cm", "meter"=>"m",
# "kilometer"=>"km", "inche"=>"in", "feet"=>"ft", "yard"=>"yd",
# "mile"=>"mi" }
#
# both short and full form are accepted in argument and case insensitive.```
## Available options for conversion
Name | Units
:---------:|:------------------------------:
Length | mm, cm, m, km, in, ft, yd, mi
Area | mm2, cm2, m2, in2, ft2, yd2
Mass | g, kg, tonne, sh_ton, l_ton, lb, oz
Volume | cm3, m3, ltr, in3, ft3, us_gal, imp_gal, us_brl
Density | g/ml kg/m3 lb/ft3 lb/in3
Volumetric Liquid flow | l/sec l/min m3 ft3/min ft3/hr gal/min brl/d
Volumetric Liquid flow | nm3/hr scfh scfm
Mass Flow | kg/h lb/h kg/s t/h
High Pressure | bar psi kpa mpa kgf/cm2 mm_hg atm
Low Pressure | mh2o fth2o cmhg inhg inh2o pa
KinematicViscosity | cs st ft2/s m2/s
Speed | m/s m/min km/h ft/s ft/min mi/h
DynamicViscosity | cp poise lb/ft·s
Torque | nm kgfm ftlb inlb
## ContributingBug reports and pull requests are welcome on GitHub at https://github.com/tanvir002700/convert_unit. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
See the [Contribution Guidelines](https://github.com/tanvir002700/convert_unit/blob/master/CONTRIBUTING.md)## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
## Code of Conduct
Everyone interacting in the ConvertUnit project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/tanvir002700/convert_unit/blob/master/CODE_OF_CONDUCT.md).