siconvert 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 34aeb12fd2e5d3852e11ed0fbf065acf49e6961c1908da4053e1cf1d41a8094b
4
+ data.tar.gz: 435a66a8c5ff3705d5e90800c537e665096e5d18526d951a3d2bfc4dec6fe8d7
5
+ SHA512:
6
+ metadata.gz: 8051b1111487a1ad913b0bbf112f7491abf9544e58dd10ffd1000d27dcf9b6eb3b02285ad4670b65210c6d3b4ca4d586dbd629b8aa0e1c863a7e85bf54016e04
7
+ data.tar.gz: 65e5bfbdb661ee386599e5c3553661b3b0d7ca0daf2c34bc7765f7628e33cec4bb7ad72faa4e20bd16cb89ba09cd3ab0e3e82714bda8b6e3c6ba5bce67bebacf
data/.DS_Store ADDED
Binary file
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem "rake", "~> 13.0"
6
+ gem "rspec", "~> 3.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,34 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ siconvert (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.5.0)
10
+ rake (13.0.6)
11
+ rspec (3.11.0)
12
+ rspec-core (~> 3.11.0)
13
+ rspec-expectations (~> 3.11.0)
14
+ rspec-mocks (~> 3.11.0)
15
+ rspec-core (3.11.0)
16
+ rspec-support (~> 3.11.0)
17
+ rspec-expectations (3.11.0)
18
+ diff-lcs (>= 1.2.0, < 2.0)
19
+ rspec-support (~> 3.11.0)
20
+ rspec-mocks (3.11.1)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.11.0)
23
+ rspec-support (3.11.0)
24
+
25
+ PLATFORMS
26
+ x86_64-darwin-20
27
+
28
+ DEPENDENCIES
29
+ rake (~> 13.0)
30
+ rspec (~> 3.0)
31
+ siconvert!
32
+
33
+ BUNDLED WITH
34
+ 2.3.7
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Kirill Leonov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # Siconvert
2
+
3
+ Gem to convert your values to SI
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'siconvert'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install siconvert
20
+
21
+ ## Usage
22
+
23
+ At the moment, the gem has 2 main methods - "fromsi", "si".
24
+
25
+ Gem works with measurements of distance, mass and speed.
26
+
27
+ - distance - (inch, feet, yard, verst) - will be converted to meters.
28
+
29
+ - mass (lb, ounce, drachma) - will be converted to kilograms.
30
+
31
+ - speed (mph) - will be converted to kilometers per hour.
32
+
33
+
34
+ Method **"fromsi"** converts your SI-value in to all possible alternative values and returns an array to you.
35
+
36
+ ```ruby
37
+ a = Siconvert.new.fromsi(2 ,"distance")
38
+ # {"inch"=>78.74, "foot"=>6.562, "yard"=>2.188, "verst"=>0.0018744142455482662}
39
+ ```
40
+
41
+ The value must already be specified in the SI system.
42
+
43
+ Method - **"si"** converts your value to SI system.
44
+
45
+ To do this, pass your value as the first argument, and a value from among those supported by this gem as the second argument.
46
+
47
+ ```ruby
48
+ a = Siconvert.new.si(50 ,"verst")
49
+ # 53350
50
+ ```
51
+
52
+
53
+
54
+ ## License
55
+
56
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,3 @@
1
+ class Siconvert
2
+ VERSION = "0.1.0"
3
+ end
data/lib/siconvert.rb ADDED
@@ -0,0 +1,56 @@
1
+ require_relative "siconvert/version"
2
+
3
+ class Siconvert
4
+
5
+ #Возвращает массив с показателями
6
+ def fromsi(value, scale)
7
+ case scale
8
+ when "distance"
9
+ result = {
10
+ "inch" => value * 39.37,
11
+ "foot" => value * 3.281,
12
+ "yard" => value * 1.094,
13
+ "verst" => value / 1067.0
14
+ }
15
+ when "weight"
16
+ result = {
17
+ "lb" => value * 2.205,
18
+ "ounce" => value * 35.274,
19
+ "drachma" => value * 257.205
20
+ }
21
+ when "speed"
22
+ result = {
23
+ "miles per hour" => value * 1.609
24
+ }
25
+ else
26
+ 'Error'
27
+ end
28
+ end
29
+ #
30
+
31
+ def si(value, scale)
32
+ case scale
33
+ when "inch"
34
+ value / 39.37
35
+ when "foot"
36
+ value / 3.281
37
+ when "yard"
38
+ value / 1.094
39
+ when "verst"
40
+ value * 1067.0
41
+ when "lb"
42
+ value / 2.205
43
+ when "ounce"
44
+ value / 35.274
45
+ when "drachma"
46
+ value / 564.0
47
+ when "miles"
48
+ value * 1.609
49
+ else
50
+ 'Error'
51
+ end
52
+ end
53
+
54
+
55
+
56
+ end
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: siconvert
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kirill Leonov
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-04-15 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Convert your values to SI
14
+ email:
15
+ - leonov835@yandex.ru
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".DS_Store"
21
+ - ".rspec"
22
+ - Gemfile
23
+ - Gemfile.lock
24
+ - LICENSE.txt
25
+ - README.md
26
+ - Rakefile
27
+ - lib/siconvert.rb
28
+ - lib/siconvert/version.rb
29
+ homepage: https://github.com/leonovk/siconvert
30
+ licenses:
31
+ - MIT
32
+ metadata:
33
+ homepage_uri: https://github.com/leonovk/siconvert
34
+ source_code_uri: https://github.com/leonovk/siconvert
35
+ post_install_message:
36
+ rdoc_options: []
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 2.6.0
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ requirements: []
50
+ rubygems_version: 3.3.7
51
+ signing_key:
52
+ specification_version: 4
53
+ summary: Convert your values to SI
54
+ test_files: []