quantitymanager 0.2.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.
- data/doc/classes/Array.html +159 -0
- data/doc/classes/Array.src/M000001.html +21 -0
- data/doc/classes/Array.src/M000002.html +19 -0
- data/doc/classes/Array.src/M000040.html +21 -0
- data/doc/classes/Array.src/M000041.html +19 -0
- data/doc/classes/CalculatorTest.html +332 -0
- data/doc/classes/CalculatorTest.src/M000022.html +33 -0
- data/doc/classes/CalculatorTest.src/M000023.html +28 -0
- data/doc/classes/CalculatorTest.src/M000024.html +25 -0
- data/doc/classes/CalculatorTest.src/M000025.html +34 -0
- data/doc/classes/CalculatorTest.src/M000026.html +27 -0
- data/doc/classes/CalculatorTest.src/M000027.html +28 -0
- data/doc/classes/CalculatorTest.src/M000028.html +26 -0
- data/doc/classes/CalculatorTest.src/M000029.html +25 -0
- data/doc/classes/CalculatorTest.src/M000030.html +26 -0
- data/doc/classes/CalculatorTest.src/M000031.html +31 -0
- data/doc/classes/CalculatorTest.src/M000032.html +23 -0
- data/doc/classes/CalculatorTest.src/M000033.html +23 -0
- data/doc/classes/CalculatorTest.src/M000034.html +32 -0
- data/doc/classes/CalculatorTest.src/M000035.html +20 -0
- data/doc/classes/CompasedUnitTest.html +279 -0
- data/doc/classes/CompasedUnitTest.src/M000001.html +32 -0
- data/doc/classes/CompasedUnitTest.src/M000002.html +31 -0
- data/doc/classes/CompasedUnitTest.src/M000003.html +28 -0
- data/doc/classes/CompasedUnitTest.src/M000004.html +28 -0
- data/doc/classes/CompasedUnitTest.src/M000005.html +31 -0
- data/doc/classes/CompasedUnitTest.src/M000006.html +23 -0
- data/doc/classes/CompasedUnitTest.src/M000007.html +30 -0
- data/doc/classes/CompasedUnitTest.src/M000008.html +24 -0
- data/doc/classes/CompasedUnitTest.src/M000009.html +27 -0
- data/doc/classes/CompasedUnitTest.src/M000010.html +24 -0
- data/doc/classes/Configuration.html +184 -0
- data/doc/classes/Configuration.src/M000003.html +19 -0
- data/doc/classes/Configuration.src/M000004.html +18 -0
- data/doc/classes/Configuration.src/M000005.html +18 -0
- data/doc/classes/Configuration.src/M000006.html +24 -0
- data/doc/classes/Configuration.src/M000042.html +19 -0
- data/doc/classes/Configuration.src/M000043.html +18 -0
- data/doc/classes/Configuration.src/M000044.html +18 -0
- data/doc/classes/Configuration.src/M000045.html +24 -0
- data/doc/classes/ConfigurationTest.html +182 -0
- data/doc/classes/ConfigurationTest.src/M000065.html +31 -0
- data/doc/classes/ConfigurationTest.src/M000066.html +27 -0
- data/doc/classes/ConfigurationTest.src/M000067.html +35 -0
- data/doc/classes/ConfigurationTest.src/M000068.html +24 -0
- data/doc/classes/CustomUnitConversionTest.html +212 -0
- data/doc/classes/CustomUnitConversionTest.src/M000052.html +31 -0
- data/doc/classes/CustomUnitConversionTest.src/M000053.html +25 -0
- data/doc/classes/CustomUnitConversionTest.src/M000054.html +20 -0
- data/doc/classes/CustomUnitConversionTest.src/M000055.html +26 -0
- data/doc/classes/CustomUnitConversionTest.src/M000056.html +26 -0
- data/doc/classes/CustomUnitConversionTest.src/M000057.html +24 -0
- data/doc/classes/Numeric.html +125 -0
- data/doc/classes/QuantifiableTest.html +189 -0
- data/doc/classes/QuantifiableTest.src/M000036.html +24 -0
- data/doc/classes/QuantifiableTest.src/M000037.html +26 -0
- data/doc/classes/QuantifiableTest.src/M000038.html +41 -0
- data/doc/classes/QuantifiableTest.src/M000039.html +23 -0
- data/doc/classes/Quantity/Calculable.html +213 -0
- data/doc/classes/Quantity/Calculable.src/M000010.html +18 -0
- data/doc/classes/Quantity/Calculable.src/M000011.html +18 -0
- data/doc/classes/Quantity/Calculable.src/M000012.html +18 -0
- data/doc/classes/Quantity/Calculable.src/M000013.html +18 -0
- data/doc/classes/Quantity/Calculable.src/M000014.html +21 -0
- data/doc/classes/Quantity/Calculable.src/M000015.html +18 -0
- data/doc/classes/Quantity/Calculable.src/M000072.html +18 -0
- data/doc/classes/Quantity/Calculable.src/M000073.html +18 -0
- data/doc/classes/Quantity/Calculable.src/M000074.html +18 -0
- data/doc/classes/Quantity/Calculable.src/M000075.html +18 -0
- data/doc/classes/Quantity/Calculable.src/M000076.html +21 -0
- data/doc/classes/Quantity/Calculable.src/M000077.html +18 -0
- data/doc/classes/Quantity/Calculator.html +240 -0
- data/doc/classes/Quantity/Calculator.src/M000021.html +20 -0
- data/doc/classes/Quantity/Calculator.src/M000022.html +18 -0
- data/doc/classes/Quantity/Calculator.src/M000023.html +26 -0
- data/doc/classes/Quantity/Calculator.src/M000024.html +23 -0
- data/doc/classes/Quantity/Calculator.src/M000025.html +31 -0
- data/doc/classes/Quantity/Calculator.src/M000026.html +25 -0
- data/doc/classes/Quantity/Calculator.src/M000083.html +20 -0
- data/doc/classes/Quantity/Calculator.src/M000084.html +18 -0
- data/doc/classes/Quantity/Calculator.src/M000085.html +26 -0
- data/doc/classes/Quantity/Calculator.src/M000086.html +23 -0
- data/doc/classes/Quantity/Calculator.src/M000087.html +31 -0
- data/doc/classes/Quantity/Calculator.src/M000088.html +25 -0
- data/doc/classes/Quantity/Measurable.html +153 -0
- data/doc/classes/Quantity/Measurable.src/M000008.html +18 -0
- data/doc/classes/Quantity/Measurable.src/M000009.html +18 -0
- data/doc/classes/Quantity/Measurable.src/M000070.html +18 -0
- data/doc/classes/Quantity/Measurable.src/M000071.html +18 -0
- data/doc/classes/Quantity/OperationInfo.html +184 -0
- data/doc/classes/Quantity/OperationInfo.src/M000027.html +24 -0
- data/doc/classes/Quantity/OperationInfo.src/M000028.html +21 -0
- data/doc/classes/Quantity/OperationInfo.src/M000089.html +24 -0
- data/doc/classes/Quantity/OperationInfo.src/M000090.html +21 -0
- data/doc/classes/Quantity/Quantifiable.html +131 -0
- data/doc/classes/Quantity/Quantifiable.src/M000007.html +18 -0
- data/doc/classes/Quantity/Quantifiable.src/M000069.html +18 -0
- data/doc/classes/Quantity/Quantity.html +211 -0
- data/doc/classes/Quantity/Quantity.src/M000016.html +20 -0
- data/doc/classes/Quantity/Quantity.src/M000017.html +20 -0
- data/doc/classes/Quantity/Quantity.src/M000018.html +20 -0
- data/doc/classes/Quantity/Quantity.src/M000078.html +20 -0
- data/doc/classes/Quantity/Quantity.src/M000079.html +20 -0
- data/doc/classes/Quantity/Quantity.src/M000080.html +20 -0
- data/doc/classes/Quantity/QuantityInfo.html +179 -0
- data/doc/classes/Quantity/QuantityInfo.src/M000019.html +19 -0
- data/doc/classes/Quantity/QuantityInfo.src/M000020.html +18 -0
- data/doc/classes/Quantity/QuantityInfo.src/M000081.html +19 -0
- data/doc/classes/Quantity/QuantityInfo.src/M000082.html +18 -0
- data/doc/classes/Quantity.html +121 -0
- data/doc/classes/QuantityTest.html +220 -0
- data/doc/classes/QuantityTest.src/M000046.html +32 -0
- data/doc/classes/QuantityTest.src/M000047.html +33 -0
- data/doc/classes/QuantityTest.src/M000048.html +27 -0
- data/doc/classes/QuantityTest.src/M000049.html +20 -0
- data/doc/classes/QuantityTest.src/M000050.html +22 -0
- data/doc/classes/QuantityTest.src/M000051.html +20 -0
- data/doc/classes/SimpleUnitTest.html +234 -0
- data/doc/classes/SimpleUnitTest.src/M000058.html +24 -0
- data/doc/classes/SimpleUnitTest.src/M000059.html +25 -0
- data/doc/classes/SimpleUnitTest.src/M000060.html +21 -0
- data/doc/classes/SimpleUnitTest.src/M000061.html +20 -0
- data/doc/classes/SimpleUnitTest.src/M000062.html +26 -0
- data/doc/classes/SimpleUnitTest.src/M000063.html +21 -0
- data/doc/classes/SimpleUnitTest.src/M000064.html +18 -0
- data/doc/classes/SpecParserTest.html +174 -0
- data/doc/classes/SpecParserTest.src/M000019.html +25 -0
- data/doc/classes/SpecParserTest.src/M000020.html +32 -0
- data/doc/classes/SpecParserTest.src/M000021.html +31 -0
- data/doc/classes/Test.html +101 -0
- data/doc/classes/Unit/Comparable.html +156 -0
- data/doc/classes/Unit/Comparable.src/M000030.html +22 -0
- data/doc/classes/Unit/Comparable.src/M000031.html +22 -0
- data/doc/classes/Unit/Comparable.src/M000092.html +22 -0
- data/doc/classes/Unit/Comparable.src/M000093.html +22 -0
- data/doc/classes/Unit/ComposedUnit.html +301 -0
- data/doc/classes/Unit/ComposedUnit.src/M000044.html +22 -0
- data/doc/classes/Unit/ComposedUnit.src/M000045.html +25 -0
- data/doc/classes/Unit/ComposedUnit.src/M000046.html +25 -0
- data/doc/classes/Unit/ComposedUnit.src/M000047.html +22 -0
- data/doc/classes/Unit/ComposedUnit.src/M000048.html +29 -0
- data/doc/classes/Unit/ComposedUnit.src/M000049.html +24 -0
- data/doc/classes/Unit/ComposedUnit.src/M000050.html +25 -0
- data/doc/classes/Unit/ComposedUnit.src/M000051.html +18 -0
- data/doc/classes/Unit/ComposedUnit.src/M000107.html +22 -0
- data/doc/classes/Unit/ComposedUnit.src/M000108.html +25 -0
- data/doc/classes/Unit/ComposedUnit.src/M000109.html +25 -0
- data/doc/classes/Unit/ComposedUnit.src/M000110.html +22 -0
- data/doc/classes/Unit/ComposedUnit.src/M000111.html +29 -0
- data/doc/classes/Unit/ComposedUnit.src/M000112.html +24 -0
- data/doc/classes/Unit/ComposedUnit.src/M000113.html +25 -0
- data/doc/classes/Unit/ComposedUnit.src/M000114.html +18 -0
- data/doc/classes/Unit/Optimizer.html +152 -0
- data/doc/classes/Unit/Optimizer.src/M000042.html +44 -0
- data/doc/classes/Unit/Optimizer.src/M000043.html +18 -0
- data/doc/classes/Unit/Optimizer.src/M000105.html +44 -0
- data/doc/classes/Unit/Optimizer.src/M000106.html +18 -0
- data/doc/classes/Unit/Parser.html +176 -0
- data/doc/classes/Unit/Parser.src/M000039.html +18 -0
- data/doc/classes/Unit/Parser.src/M000040.html +25 -0
- data/doc/classes/Unit/Parser.src/M000041.html +19 -0
- data/doc/classes/Unit/Parser.src/M000102.html +18 -0
- data/doc/classes/Unit/Parser.src/M000103.html +25 -0
- data/doc/classes/Unit/Parser.src/M000104.html +19 -0
- data/doc/classes/Unit/SimpleUnit.html +287 -0
- data/doc/classes/Unit/SimpleUnit.src/M000032.html +20 -0
- data/doc/classes/Unit/SimpleUnit.src/M000033.html +20 -0
- data/doc/classes/Unit/SimpleUnit.src/M000034.html +20 -0
- data/doc/classes/Unit/SimpleUnit.src/M000035.html +20 -0
- data/doc/classes/Unit/SimpleUnit.src/M000036.html +18 -0
- data/doc/classes/Unit/SimpleUnit.src/M000037.html +21 -0
- data/doc/classes/Unit/SimpleUnit.src/M000038.html +18 -0
- data/doc/classes/Unit/SimpleUnit.src/M000094.html +20 -0
- data/doc/classes/Unit/SimpleUnit.src/M000095.html +20 -0
- data/doc/classes/Unit/SimpleUnit.src/M000096.html +20 -0
- data/doc/classes/Unit/SimpleUnit.src/M000097.html +20 -0
- data/doc/classes/Unit/SimpleUnit.src/M000098.html +18 -0
- data/doc/classes/Unit/SimpleUnit.src/M000099.html +21 -0
- data/doc/classes/Unit/SimpleUnit.src/M000100.html +18 -0
- data/doc/classes/Unit/SymbolConverter.html +131 -0
- data/doc/classes/Unit/SymbolConverter.src/M000029.html +24 -0
- data/doc/classes/Unit/SymbolConverter.src/M000091.html +24 -0
- data/doc/classes/Unit/TestCase.html +146 -0
- data/doc/classes/Unit/TestCase.src/M000101.html +24 -0
- data/doc/classes/Unit.html +120 -0
- data/doc/classes/UnitOptemizerTest.html +249 -0
- data/doc/classes/UnitOptemizerTest.src/M000011.html +31 -0
- data/doc/classes/UnitOptemizerTest.src/M000012.html +25 -0
- data/doc/classes/UnitOptemizerTest.src/M000013.html +27 -0
- data/doc/classes/UnitOptemizerTest.src/M000014.html +27 -0
- data/doc/classes/UnitOptemizerTest.src/M000015.html +27 -0
- data/doc/classes/UnitOptemizerTest.src/M000016.html +26 -0
- data/doc/classes/UnitOptemizerTest.src/M000017.html +23 -0
- data/doc/classes/UnitOptemizerTest.src/M000018.html +22 -0
- data/doc/created.rid +1 -0
- data/doc/files/config/default_configuration_rb.html +108 -0
- data/doc/files/quantity_rb.html +113 -0
- data/doc/files/test/all_tests_rb.html +108 -0
- data/doc/files/test/test_helper_rb.html +110 -0
- data/doc/files/test/unit/calculator_test_rb.html +109 -0
- data/doc/files/test/unit/composed_unit_test_rb.html +101 -0
- data/doc/files/test/unit/configuration_test_rb.html +109 -0
- data/doc/files/test/unit/custom_conversion_test_rb.html +109 -0
- data/doc/files/test/unit/quantifiable_test_rb.html +101 -0
- data/doc/files/test/unit/quantity_test_rb.html +101 -0
- data/doc/files/test/unit/simple_unit_test_rb.html +101 -0
- data/doc/files/test/unit/unit_optimizer_test_rb.html +101 -0
- data/doc/files/test/unit/unit_spec_parser_test_rb.html +101 -0
- data/doc/files/unitmanager/calculator_rb.html +101 -0
- data/doc/files/unitmanager/configuration_rb.html +101 -0
- data/doc/files/unitmanager/quantity_rb.html +101 -0
- data/doc/files/unitmanager/simple_unit_rb.html +108 -0
- data/doc/files/unitmanager/unit_composition_rb.html +101 -0
- data/doc/fr_class_index.html +44 -0
- data/doc/fr_file_index.html +33 -0
- data/doc/fr_method_index.html +77 -0
- data/doc/index.html +24 -0
- data/lib/config/default_configuration.rb +115 -0
- data/lib/quantity.rb +34 -0
- data/lib/unitmanager/calculator.rb +195 -0
- data/lib/unitmanager/configuration.rb +26 -0
- data/lib/unitmanager/quantity.rb +167 -0
- data/lib/unitmanager/simple_unit.rb +155 -0
- data/lib/unitmanager/unit_composition.rb +217 -0
- data/test/all_tests.rb +8 -0
- data/test/calculator_test.rb +194 -0
- data/test/composed_unit_test.rb +169 -0
- data/test/configuration_test.rb +70 -0
- data/test/custom_conversion_test.rb +90 -0
- data/test/quantifiable_test.rb +73 -0
- data/test/quantity_test.rb +79 -0
- data/test/simple_unit_test.rb +59 -0
- data/test/test_helper.rb +18 -0
- data/test/unit_optimizer_test.rb +104 -0
- data/test/unit_spec_parser_test.rb +50 -0
- metadata +307 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>+ (Quantity::Calculable)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File unitmanager/quantity.rb, line 12</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">value</span>)
|
15
|
+
<span class="ruby-identifier">perform_operation</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">:+</span>)
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>- (Quantity::Calculable)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File unitmanager/quantity.rb, line 16</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">-</span> (<span class="ruby-identifier">value</span>)
|
15
|
+
<span class="ruby-identifier">perform_operation</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">:-</span>)
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>* (Quantity::Calculable)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File unitmanager/quantity.rb, line 20</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">*</span> (<span class="ruby-identifier">value</span>)
|
15
|
+
<span class="ruby-identifier">perform_operation</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">:*</span>)
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>/ (Quantity::Calculable)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File unitmanager/quantity.rb, line 24</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">/</span> (<span class="ruby-identifier">value</span>)
|
15
|
+
<span class="ruby-identifier">perform_operation</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">:/</span>)
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>== (Quantity::Calculable)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File unitmanager/quantity.rb, line 28</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">==</span> (<span class="ruby-identifier">other</span>)
|
15
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">other</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span>
|
16
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>)
|
17
|
+
|
18
|
+
<span class="ruby-identifier">value</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">value</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">unit</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">unit</span>
|
19
|
+
<span class="ruby-keyword kw">end</span></pre>
|
20
|
+
</body>
|
21
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>coerce (Quantity::Calculable)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File unitmanager/quantity.rb, line 35</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">coerce</span>(<span class="ruby-identifier">other</span>)
|
15
|
+
[<span class="ruby-constant">QuantityInfo</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">other</span>, <span class="ruby-keyword kw">nil</span>), <span class="ruby-keyword kw">self</span>]
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,240 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: Quantity::Calculator</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">Quantity::Calculator</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/unitmanager/calculator_rb.html">
|
59
|
+
unitmanager/calculator.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
Object
|
69
|
+
</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
</div>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<div id="contextContent">
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
</div>
|
84
|
+
|
85
|
+
<div id="method-list">
|
86
|
+
<h3 class="section-bar">Methods</h3>
|
87
|
+
|
88
|
+
<div class="name-list">
|
89
|
+
<a href="#M000026">add_conversion</a>
|
90
|
+
<a href="#M000025">add_unit</a>
|
91
|
+
<a href="#M000024">exp</a>
|
92
|
+
<a href="#M000021">new</a>
|
93
|
+
<a href="#M000023">perform_operation</a>
|
94
|
+
<a href="#M000022">quantity</a>
|
95
|
+
</div>
|
96
|
+
</div>
|
97
|
+
|
98
|
+
</div>
|
99
|
+
|
100
|
+
|
101
|
+
<!-- if includes -->
|
102
|
+
<div id="includes">
|
103
|
+
<h3 class="section-bar">Included Modules</h3>
|
104
|
+
|
105
|
+
<div id="includes-list">
|
106
|
+
<span class="include-name"><a href="Quantifiable.html">Quantifiable</a></span>
|
107
|
+
<span class="include-name"><a href="../Unit/SymbolConverter.html">Unit::SymbolConverter</a></span>
|
108
|
+
</div>
|
109
|
+
</div>
|
110
|
+
|
111
|
+
<div id="section">
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
<div id="attribute-list">
|
118
|
+
<h3 class="section-bar">Attributes</h3>
|
119
|
+
|
120
|
+
<div class="name-list">
|
121
|
+
<table>
|
122
|
+
<tr class="top-aligned-row context-row">
|
123
|
+
<td class="context-item-name">conversions</td>
|
124
|
+
<td class="context-item-value"> [R] </td>
|
125
|
+
<td class="context-item-desc"></td>
|
126
|
+
</tr>
|
127
|
+
<tr class="top-aligned-row context-row">
|
128
|
+
<td class="context-item-name">units</td>
|
129
|
+
<td class="context-item-value"> [R] </td>
|
130
|
+
<td class="context-item-desc"></td>
|
131
|
+
</tr>
|
132
|
+
</table>
|
133
|
+
</div>
|
134
|
+
</div>
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
<!-- if method_list -->
|
139
|
+
<div id="methods">
|
140
|
+
<h3 class="section-bar">Public Class methods</h3>
|
141
|
+
|
142
|
+
<div id="method-M000021" class="method-detail">
|
143
|
+
<a name="M000021"></a>
|
144
|
+
|
145
|
+
<div class="method-heading">
|
146
|
+
<a href="Calculator.src/M000021.html" target="Code" class="method-signature"
|
147
|
+
onclick="popupCode('Calculator.src/M000021.html');return false;">
|
148
|
+
<span class="method-name">new</span><span class="method-args">(units = {}, conversions = [])</span>
|
149
|
+
</a>
|
150
|
+
</div>
|
151
|
+
|
152
|
+
<div class="method-description">
|
153
|
+
</div>
|
154
|
+
</div>
|
155
|
+
|
156
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
157
|
+
|
158
|
+
<div id="method-M000026" class="method-detail">
|
159
|
+
<a name="M000026"></a>
|
160
|
+
|
161
|
+
<div class="method-heading">
|
162
|
+
<a href="Calculator.src/M000026.html" target="Code" class="method-signature"
|
163
|
+
onclick="popupCode('Calculator.src/M000026.html');return false;">
|
164
|
+
<span class="method-name">add_conversion</span><span class="method-args">(params)</span>
|
165
|
+
</a>
|
166
|
+
</div>
|
167
|
+
|
168
|
+
<div class="method-description">
|
169
|
+
</div>
|
170
|
+
</div>
|
171
|
+
|
172
|
+
<div id="method-M000025" class="method-detail">
|
173
|
+
<a name="M000025"></a>
|
174
|
+
|
175
|
+
<div class="method-heading">
|
176
|
+
<a href="Calculator.src/M000025.html" target="Code" class="method-signature"
|
177
|
+
onclick="popupCode('Calculator.src/M000025.html');return false;">
|
178
|
+
<span class="method-name">add_unit</span><span class="method-args">(params)</span>
|
179
|
+
</a>
|
180
|
+
</div>
|
181
|
+
|
182
|
+
<div class="method-description">
|
183
|
+
</div>
|
184
|
+
</div>
|
185
|
+
|
186
|
+
<div id="method-M000024" class="method-detail">
|
187
|
+
<a name="M000024"></a>
|
188
|
+
|
189
|
+
<div class="method-heading">
|
190
|
+
<a href="Calculator.src/M000024.html" target="Code" class="method-signature"
|
191
|
+
onclick="popupCode('Calculator.src/M000024.html');return false;">
|
192
|
+
<span class="method-name">exp</span><span class="method-args">(return_as = nil) {|self| ...}</span>
|
193
|
+
</a>
|
194
|
+
</div>
|
195
|
+
|
196
|
+
<div class="method-description">
|
197
|
+
</div>
|
198
|
+
</div>
|
199
|
+
|
200
|
+
<div id="method-M000023" class="method-detail">
|
201
|
+
<a name="M000023"></a>
|
202
|
+
|
203
|
+
<div class="method-heading">
|
204
|
+
<a href="Calculator.src/M000023.html" target="Code" class="method-signature"
|
205
|
+
onclick="popupCode('Calculator.src/M000023.html');return false;">
|
206
|
+
<span class="method-name">perform_operation</span><span class="method-args">(first_operand, second_operand, operation)</span>
|
207
|
+
</a>
|
208
|
+
</div>
|
209
|
+
|
210
|
+
<div class="method-description">
|
211
|
+
</div>
|
212
|
+
</div>
|
213
|
+
|
214
|
+
<div id="method-M000022" class="method-detail">
|
215
|
+
<a name="M000022"></a>
|
216
|
+
|
217
|
+
<div class="method-heading">
|
218
|
+
<a href="Calculator.src/M000022.html" target="Code" class="method-signature"
|
219
|
+
onclick="popupCode('Calculator.src/M000022.html');return false;">
|
220
|
+
<span class="method-name">quantity</span><span class="method-args">(value, unit_sym)</span>
|
221
|
+
</a>
|
222
|
+
</div>
|
223
|
+
|
224
|
+
<div class="method-description">
|
225
|
+
</div>
|
226
|
+
</div>
|
227
|
+
|
228
|
+
|
229
|
+
</div>
|
230
|
+
|
231
|
+
|
232
|
+
</div>
|
233
|
+
|
234
|
+
|
235
|
+
<div id="validator-badges">
|
236
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
237
|
+
</div>
|
238
|
+
|
239
|
+
</body>
|
240
|
+
</html>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>new (Quantity::Calculator)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre> <span class="ruby-comment cmt"># File unitmanager/calculator.rb, line 9</span>
|
14
|
+
9: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">units</span> = {}, <span class="ruby-identifier">conversions</span> = [])
|
15
|
+
10: <span class="ruby-ivar">@units</span> = <span class="ruby-identifier">units</span>
|
16
|
+
11: <span class="ruby-ivar">@parser</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">Unit</span><span class="ruby-operator">::</span><span class="ruby-constant">Parser</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@units</span>)
|
17
|
+
12: <span class="ruby-ivar">@conversions</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">conversions</span>
|
18
|
+
13: <span class="ruby-keyword kw">end</span></pre>
|
19
|
+
</body>
|
20
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>quantity (Quantity::Calculator)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre> <span class="ruby-comment cmt"># File unitmanager/calculator.rb, line 15</span>
|
14
|
+
15: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">quantity</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">unit_sym</span>)
|
15
|
+
16: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Quantity</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>, {<span class="ruby-identifier">:value</span> =<span class="ruby-operator">></span> <span class="ruby-value">1.0</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">value</span>, <span class="ruby-identifier">:unit</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">result_unit</span>(<span class="ruby-identifier">unit_sym</span>)})
|
16
|
+
17: <span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>perform_operation (Quantity::Calculator)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre> <span class="ruby-comment cmt"># File unitmanager/calculator.rb, line 19</span>
|
14
|
+
19: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">perform_operation</span>(<span class="ruby-identifier">first_operand</span>, <span class="ruby-identifier">second_operand</span>, <span class="ruby-identifier">operation</span>)
|
15
|
+
20: <span class="ruby-identifier">result</span> = <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">operation</span>
|
16
|
+
21: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:+</span> <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">add</span>(<span class="ruby-identifier">first_operand</span>, <span class="ruby-identifier">second_operand</span>)
|
17
|
+
22: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:-</span> <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">subtract</span>(<span class="ruby-identifier">first_operand</span>, <span class="ruby-identifier">second_operand</span>)
|
18
|
+
23: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:*</span> <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">multiply</span>(<span class="ruby-identifier">first_operand</span>, <span class="ruby-identifier">second_operand</span>)
|
19
|
+
24: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:/</span> <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">divide</span>(<span class="ruby-identifier">first_operand</span>, <span class="ruby-identifier">second_operand</span>)
|
20
|
+
25: <span class="ruby-keyword kw">else</span>
|
21
|
+
26: <span class="ruby-identifier">raise</span> <span class="ruby-node">"Operation #{operation.to_s} is not supported"</span>
|
22
|
+
27: <span class="ruby-keyword kw">end</span>
|
23
|
+
28: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">result</span>
|
24
|
+
29: <span class="ruby-keyword kw">end</span></pre>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>exp (Quantity::Calculator)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre> <span class="ruby-comment cmt"># File unitmanager/calculator.rb, line 31</span>
|
14
|
+
31: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">exp</span> (<span class="ruby-identifier">return_as</span> = <span class="ruby-keyword kw">nil</span>)
|
15
|
+
32:
|
16
|
+
33: <span class="ruby-identifier">operand</span> = <span class="ruby-keyword kw">yield</span> <span class="ruby-keyword kw">self</span>
|
17
|
+
34: <span class="ruby-identifier">raise</span> <span class="ruby-value str">"Operand is not Quantifiable"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">quantifiable?</span>(<span class="ruby-identifier">operand</span>)
|
18
|
+
35:
|
19
|
+
36:
|
20
|
+
37: <span class="ruby-identifier">convert_to</span>(<span class="ruby-identifier">operand</span>.<span class="ruby-identifier">to_quantity</span>(<span class="ruby-keyword kw">self</span>), <span class="ruby-identifier">result_unit</span>(<span class="ruby-identifier">return_as</span>))
|
21
|
+
38: <span class="ruby-keyword kw">end</span></pre>
|
22
|
+
</body>
|
23
|
+
</html>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>add_unit (Quantity::Calculator)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre> <span class="ruby-comment cmt"># File unitmanager/calculator.rb, line 40</span>
|
14
|
+
40: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_unit</span>(<span class="ruby-identifier">params</span>)
|
15
|
+
41: <span class="ruby-identifier">raise</span> <span class="ruby-value str">"Unit symbol is required"</span> <span class="ruby-keyword kw">unless</span> (<span class="ruby-identifier">unit_sym</span> = <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:unit</span>])
|
16
|
+
42:
|
17
|
+
43: <span class="ruby-identifier">raise</span> <span class="ruby-node">"Unit with symbol: #{unit_sym.to_s} already defined"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@units</span>[<span class="ruby-identifier">unit_sym</span>]
|
18
|
+
44:
|
19
|
+
45: <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">based_on_sym</span> = <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:based_on</span>])
|
20
|
+
46: <span class="ruby-identifier">raise</span> <span class="ruby-value str">"Invalid configuration. "</span> <span class="ruby-operator">+</span>
|
21
|
+
47: <span class="ruby-value str">"Based_on unit must be defined before used."</span> <span class="ruby-keyword kw">unless</span> (<span class="ruby-identifier">based_on</span> = <span class="ruby-ivar">@units</span>[<span class="ruby-identifier">based_on_sym</span>])
|
22
|
+
48: <span class="ruby-keyword kw">end</span>
|
23
|
+
49:
|
24
|
+
50: <span class="ruby-ivar">@units</span>[<span class="ruby-identifier">unit_sym</span>] = <span class="ruby-constant">Unit</span><span class="ruby-operator">::</span><span class="ruby-constant">SimpleUnit</span>.<span class="ruby-identifier">new</span>({
|
25
|
+
51: <span class="ruby-identifier">:unit</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">unit_sym</span>,
|
26
|
+
52: <span class="ruby-identifier">:based_on</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">based_on</span>,
|
27
|
+
53: <span class="ruby-identifier">:coefficient</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:coefficient</span>] <span class="ruby-operator">||</span> <span class="ruby-value">1.0</span>
|
28
|
+
54: })
|
29
|
+
55: <span class="ruby-keyword kw">end</span></pre>
|
30
|
+
</body>
|
31
|
+
</html>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>add_conversion (Quantity::Calculator)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre> <span class="ruby-comment cmt"># File unitmanager/calculator.rb, line 57</span>
|
14
|
+
57: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_conversion</span>(<span class="ruby-identifier">params</span>)
|
15
|
+
58: <span class="ruby-identifier">params</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">source</span>, <span class="ruby-identifier">target</span><span class="ruby-operator">|</span>
|
16
|
+
59: <span class="ruby-keyword kw">begin</span>
|
17
|
+
60: <span class="ruby-ivar">@conversions</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">exp</span> { <span class="ruby-identifier">target</span> <span class="ruby-operator">/</span> <span class="ruby-identifier">source</span> }
|
18
|
+
61: <span class="ruby-ivar">@conversions</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">exp</span> { <span class="ruby-identifier">source</span> <span class="ruby-operator">/</span> <span class="ruby-identifier">target</span> }
|
19
|
+
62: <span class="ruby-keyword kw">rescue</span>
|
20
|
+
63: <span class="ruby-identifier">raise</span> <span class="ruby-value str">"Unit must be defined before used in conversion"</span>
|
21
|
+
64: <span class="ruby-keyword kw">end</span>
|
22
|
+
65: }
|
23
|
+
66: <span class="ruby-keyword kw">end</span></pre>
|
24
|
+
</body>
|
25
|
+
</html>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>new (Quantity::Calculator)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File unitmanager/calculator.rb, line 9</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">units</span> = {}, <span class="ruby-identifier">conversions</span> = [])
|
15
|
+
<span class="ruby-ivar">@units</span> = <span class="ruby-identifier">units</span>
|
16
|
+
<span class="ruby-ivar">@parser</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">Unit</span><span class="ruby-operator">::</span><span class="ruby-constant">Parser</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@units</span>)
|
17
|
+
<span class="ruby-ivar">@conversions</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">conversions</span>
|
18
|
+
<span class="ruby-keyword kw">end</span></pre>
|
19
|
+
</body>
|
20
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>quantity (Quantity::Calculator)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File unitmanager/calculator.rb, line 15</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">quantity</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">unit_sym</span>)
|
15
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-constant">Quantity</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>, {<span class="ruby-identifier">:value</span> =<span class="ruby-operator">></span> <span class="ruby-value">1.0</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">value</span>, <span class="ruby-identifier">:unit</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">result_unit</span>(<span class="ruby-identifier">unit_sym</span>)})
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>perform_operation (Quantity::Calculator)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File unitmanager/calculator.rb, line 19</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">perform_operation</span>(<span class="ruby-identifier">first_operand</span>, <span class="ruby-identifier">second_operand</span>, <span class="ruby-identifier">operation</span>)
|
15
|
+
<span class="ruby-identifier">result</span> = <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">operation</span>
|
16
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:+</span> <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">add</span>(<span class="ruby-identifier">first_operand</span>, <span class="ruby-identifier">second_operand</span>)
|
17
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:-</span> <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">subtract</span>(<span class="ruby-identifier">first_operand</span>, <span class="ruby-identifier">second_operand</span>)
|
18
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:*</span> <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">multiply</span>(<span class="ruby-identifier">first_operand</span>, <span class="ruby-identifier">second_operand</span>)
|
19
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:/</span> <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">divide</span>(<span class="ruby-identifier">first_operand</span>, <span class="ruby-identifier">second_operand</span>)
|
20
|
+
<span class="ruby-keyword kw">else</span>
|
21
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-node">"Operation #{operation.to_s} is not supported"</span>
|
22
|
+
<span class="ruby-keyword kw">end</span>
|
23
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">result</span>
|
24
|
+
<span class="ruby-keyword kw">end</span></pre>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>exp (Quantity::Calculator)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File unitmanager/calculator.rb, line 31</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">exp</span> (<span class="ruby-identifier">return_as</span> = <span class="ruby-keyword kw">nil</span>)
|
15
|
+
|
16
|
+
<span class="ruby-identifier">operand</span> = <span class="ruby-keyword kw">yield</span> <span class="ruby-keyword kw">self</span>
|
17
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-value str">"Operand is not Quantifiable"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">quantifiable?</span>(<span class="ruby-identifier">operand</span>)
|
18
|
+
|
19
|
+
|
20
|
+
<span class="ruby-identifier">convert_to</span>(<span class="ruby-identifier">operand</span>.<span class="ruby-identifier">to_quantity</span>(<span class="ruby-keyword kw">self</span>), <span class="ruby-identifier">result_unit</span>(<span class="ruby-identifier">return_as</span>))
|
21
|
+
<span class="ruby-keyword kw">end</span></pre>
|
22
|
+
</body>
|
23
|
+
</html>
|