engineer_calculator 1.0.0 → 1.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c77106c45d3b8780498f59edf55b43c4497ee19de2ddd049d81d165d044e1a36
4
- data.tar.gz: 4f33b68bd38c301b5d72064a75cec3e34968b42ef5bf72912af5006f5688be58
3
+ metadata.gz: e20b5435468fb2129335ff92e629c8dee115fa730552bf7b40c70e837f6943f1
4
+ data.tar.gz: ffdf69a3434ad682faf44df8aaa6d60444f747a904481c2a852311d8f59912c3
5
5
  SHA512:
6
- metadata.gz: d97d53a8f058b81be2ca4b012bd38ed69651b256d91657de13994b153f4c8e5e7da1c999ee1c437b524ffebba5c0fffeb45ea14490fa897ecaba6f740ce3e969
7
- data.tar.gz: ac3f643d9598a87772a6dcffa7c5604f6ee87b4cfd36af3eebbbc5c7c05da3045f5278dfebe2baf5349351c9e08655d05bbf423a07dc6b56d5cf1eaab12f1ca5
6
+ metadata.gz: cbcba9f27269255e2287c96439d7b5b14f1503d27f9b587bf7b988c6316602873fe57bf17cb53a84621aaa1703cf603afbf5ab7b42c8d119501af10744c0765b
7
+ data.tar.gz: b35f2493b81df625b145773ae831e13d1bf4dce1cf8da4d3be039fcac4ef1ee01ac0f5be44a2b66a3c55be2b45ade0edb40840ac430d05112ae3bc94deec8a7c
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.0
1
+ 2.6.2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- engineer_calculator (0.1.0)
4
+ engineer_calculator (1.0.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -19,4 +19,4 @@ DEPENDENCIES
19
19
  rake (~> 10.0)
20
20
 
21
21
  BUNDLED WITH
22
- 1.16.6
22
+ 1.17.2
data/README.md CHANGED
@@ -1,67 +1,5 @@
1
1
  # Engineer Calculator
2
2
 
3
- ### a. 使い方
4
- calc = EngineeringCalculator.new("100kgg / 20mm2")
5
- calc.result #=> ["5Mpa","100kgg/20mm2"]
6
- calc.calc("10mpa + 20psi")
7
- calc.result #=> ["30Mpa","10Mpa+20Mpa"]
8
- calc.evaluate("100mpa +10m") #=> fail
9
-
10
- ### b. 実装計画
11
- #### 1) 数式を取り出す
12
- 1. (), \*, / を評価して配列に代入
13
- ~~~
14
- 100kg / 20mm2 + 10psi #=> [100kg/20mm2,+,10psi,=]
15
-
16
- ex: (100kgg + 10pondg) / 20kg/mm2 + 10psi #=> [100kgg+ 10pondg,/,20mm2,+,10psi,=]
17
- ~~~
18
- 2.
19
- 2. 配列に変換
20
- ~~~
21
- [[数式,数値,単位]]
22
- ~~~
23
- #### 2) Validate?メソッドで単位の並びを評価
24
- 1. 単位評価
25
- +, - で同じカテゴリーに属していない単位が選択されていたらFailを返して終了。
26
- ~~~
27
- Mpa + psi => true
28
- Mpa * Mpa/s => true
29
- Mpa + m => fail
30
- Mpa + kg => fail
31
- ~~~
32
-
33
- 2. 計算式評価
34
- ()の数が間違っている。一番最後の)抜きはOK。
35
- ~~~
36
- ((100kg/20m2 + 20psi) + 20 => true
37
- (20+10) * 100mpa) => fail
38
- ~~~
39
- //, ** など計算式が連続している。
40
-
41
- 3. 単位抜き
42
-
43
-
44
- #### 3) 単位換算
45
- 1. メモ書き
46
- \*,/は単位無しの倍数とみなす。
47
- ~~~
48
- 100 * 20mpa #=> 20000Mpa
49
- ~~~
50
- +,-並びに記載されているもので単位が一つしかない時は、その単位とする。
51
- ~~~
52
- 100 + 20psi => 100Mpa + 20psi
53
- ~~~
54
- 2. 単位換算表(yml形式)
55
-
56
-
57
- #### 4) 数値計算
58
- 1. 数式だけを取り出す
59
- 2. evalを使用して計算する
60
-
61
- #### 5) 単位計算
62
- 1. 単位を計算するメソッドの用意
63
-
64
-
65
3
  ## Installation
66
4
 
67
5
  Add this line to your application's Gemfile:
@@ -78,9 +16,49 @@ Or install it yourself as:
78
16
 
79
17
  $ gem install engineering_calculator
80
18
 
81
- ## Usage
19
+ For web site of calculator, please visit following link.
20
+ https://eng.eastazy.work/calculator
21
+
22
+ ### How to use
23
+
24
+ If your current directory is engineer_calcululator gem,
25
+ please run "Rackup". Then access to http://localhost:9292/ , you can find web page.
26
+
27
+ Add following into your code.
28
+ ```ruby
29
+ require 'engineer_calculator'
30
+ ```
31
+
32
+ Then make instance.
82
33
 
83
- TODO: Write usage instructions here
34
+ ```ruby
35
+ eng_calc = Engineer::Calculator.new
36
+ ```
37
+
38
+ After make instance you can get calculation reulst by "calc" method.
39
+ Conversion always perform by SI base unit.
40
+ ```ruby
41
+ eng_calc.calc("10cm+20m")
42
+ => {:value=>"20.1", :unit=>"m", :convert_formula=>"0.1(m)+ 20(m) "}
43
+ ```
44
+
45
+ After calc method, you can get alter unit result by "alter" method.
46
+ ```ruby
47
+ eng_calc.alter
48
+ => {:si_unit=>[["Length", nil]],
49
+ :variable=>[["Length",
50
+ [["Å", 201000000000.0],
51
+ ["mil", 791338.5826771759],
52
+ ["in", 791.3385826771759],
53
+ ["ft", 65.94488188976331],
54
+ ["yd", 21.98162729658777], ...]]]}
55
+ ```
56
+
57
+ If conversion has any error, you can get error message by "error" method.
58
+ ```ruby
59
+ eng_calc.error
60
+ => {}
61
+ ```
84
62
 
85
63
  ## Development
86
64
 
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "./lib/engineer_calculator/engineer_calculator"
4
+ require "./lib/engineer_calculator"
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -1,4 +1,4 @@
1
- #require "engineering_calculator/version"
1
+ require "engineer_calculator/version"
2
2
  require 'yaml'
3
3
 
4
4
  module Engineer
@@ -305,23 +305,23 @@ module Engineer
305
305
  end
306
306
 
307
307
  def si_base_unit
308
- @si_base_unit ||= YAML.load_file(File.join(__dir__, 'si_base_unit.yml'))
308
+ @si_base_unit ||= YAML.load_file(File.join(__dir__, '/unit/si_base_unit.yml'))
309
309
  end
310
310
 
311
311
  def si_derived_unit
312
- @si_derived_unit ||= YAML.load_file(File.join(__dir__, 'si_derived_unit.yml'))
312
+ @si_derived_unit ||= YAML.load_file(File.join(__dir__, 'unit/si_derived_unit.yml'))
313
313
  end
314
314
 
315
315
  def variable_unit
316
- @variable_unit ||= YAML.load_file(File.join(__dir__, 'variable_unit.yml'))
316
+ @variable_unit ||= YAML.load_file(File.join(__dir__, 'unit/variable_unit.yml'))
317
317
  end
318
318
 
319
319
  def metric_prefix_unit
320
- @metric_prefix ||= YAML.load_file(File.join(__dir__, 'metric_prefix.yml'))
320
+ @metric_prefix ||= YAML.load_file(File.join(__dir__, 'unit/metric_prefix.yml'))
321
321
  end
322
322
 
323
323
  def si_alter_unit
324
- @si_alter_unit ||= YAML.load_file(File.join(__dir__, 'si_alter_unit.yml'))
324
+ @si_alter_unit ||= YAML.load_file(File.join(__dir__, 'unit/si_alter_unit.yml'))
325
325
  end
326
326
 
327
327
  def reg(kind_of_unit)
@@ -1,3 +1,3 @@
1
1
  module Engineer
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
File without changes
File without changes
File without changes
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: engineer_calculator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Azeroyear
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-23 00:00:00.000000000 Z
11
+ date: 2019-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -73,14 +73,14 @@ files:
73
73
  - config.ru
74
74
  - engineering_calculator.gemspec
75
75
  - favicon.ico
76
- - lib/convert_to_japanese.yml
77
76
  - lib/engineer_calculator.rb
78
77
  - lib/engineer_calculator/version.rb
79
- - lib/metric_prefix.yml
80
- - lib/si_alter_unit.yml
81
- - lib/si_base_unit.yml
82
- - lib/si_derived_unit.yml
83
- - lib/variable_unit.yml
78
+ - lib/unit/convert_to_japanese.yml
79
+ - lib/unit/metric_prefix.yml
80
+ - lib/unit/si_alter_unit.yml
81
+ - lib/unit/si_base_unit.yml
82
+ - lib/unit/si_derived_unit.yml
83
+ - lib/unit/variable_unit.yml
84
84
  homepage: https://github.com/AZeroyear/engineering_calculator
85
85
  licenses:
86
86
  - MIT
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0'
102
102
  requirements: []
103
- rubygems_version: 3.0.1
103
+ rubygems_version: 3.0.3
104
104
  signing_key:
105
105
  specification_version: 4
106
106
  summary: This gem can calculate the calculation which included unit.