eymiha_units 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/gem_package.rb +4 -4
- data/html/classes/Eymiha/AmbiguousUnitsException.html +119 -0
- data/html/classes/Eymiha/MissingUnitsException.html +119 -0
- data/html/classes/Eymiha/NumericWithUnits.html +867 -0
- data/html/classes/Eymiha/NumericWithUnits.src/M000021.html +18 -0
- data/html/classes/Eymiha/NumericWithUnits.src/M000022.html +18 -0
- data/html/classes/Eymiha/NumericWithUnits.src/M000023.html +18 -0
- data/html/classes/Eymiha/NumericWithUnits.src/M000024.html +30 -0
- data/html/classes/Eymiha/NumericWithUnits.src/M000025.html +30 -0
- data/html/classes/Eymiha/NumericWithUnits.src/M000027.html +18 -0
- data/html/classes/Eymiha/NumericWithUnits.src/M000028.html +20 -0
- data/html/classes/Eymiha/NumericWithUnits.src/M000029.html +32 -0
- data/html/classes/Eymiha/NumericWithUnits.src/M000030.html +18 -0
- data/html/classes/Eymiha/NumericWithUnits.src/M000031.html +30 -0
- data/html/classes/Eymiha/NumericWithUnits.src/M000032.html +30 -0
- data/html/classes/Eymiha/NumericWithUnits.src/M000033.html +22 -0
- data/html/classes/Eymiha/NumericWithUnits.src/M000034.html +22 -0
- data/html/classes/Eymiha/NumericWithUnits.src/M000035.html +32 -0
- data/html/classes/Eymiha/NumericWithUnits.src/M000036.html +32 -0
- data/html/classes/Eymiha/NumericWithUnits.src/M000037.html +18 -0
- data/html/classes/Eymiha/NumericWithUnits.src/M000038.html +18 -0
- data/html/classes/Eymiha/NumericWithUnits.src/M000039.html +24 -0
- data/html/classes/Eymiha/NumericWithUnits.src/M000040.html +26 -0
- data/html/classes/Eymiha/NumericWithUnits.src/M000041.html +18 -0
- data/html/classes/Eymiha/NumericWithUnits.src/M000042.html +18 -0
- data/html/classes/Eymiha/NumericWithUnits.src/M000043.html +18 -0
- data/html/classes/Eymiha/NumericWithUnits.src/M000044.html +20 -0
- data/html/classes/Eymiha/NumericWithUnits.src/M000045.html +18 -0
- data/html/classes/Eymiha/NumericWithUnits.src/M000046.html +25 -0
- data/html/classes/Eymiha/NumericWithUnits.src/M000047.html +18 -0
- data/html/classes/Eymiha/NumericWithUnits.src/M000048.html +19 -0
- data/html/classes/Eymiha/Units.html +378 -0
- data/html/classes/Eymiha/Units.src/M000052.html +18 -0
- data/html/classes/Eymiha/Units.src/M000053.html +18 -0
- data/html/classes/Eymiha/Units.src/M000054.html +20 -0
- data/html/classes/Eymiha/Units.src/M000055.html +30 -0
- data/html/classes/Eymiha/Units.src/M000056.html +33 -0
- data/html/classes/Eymiha/Units.src/M000057.html +18 -0
- data/html/classes/Eymiha/Units.src/M000058.html +21 -0
- data/html/classes/Eymiha/Units.src/M000059.html +18 -0
- data/html/classes/Eymiha/Units.src/M000060.html +18 -0
- data/html/classes/Eymiha/Units.src/M000061.html +18 -0
- data/html/classes/Eymiha/Units.src/M000062.html +18 -0
- data/html/classes/Eymiha/Units.src/M000063.html +18 -0
- data/html/classes/Eymiha/Units.src/M000064.html +28 -0
- data/html/classes/Eymiha/UnitsException.html +119 -0
- data/html/classes/Eymiha/UnitsHash.html +351 -0
- data/html/classes/Eymiha/UnitsHash.src/M000002.html +18 -0
- data/html/classes/Eymiha/UnitsHash.src/M000003.html +26 -0
- data/html/classes/Eymiha/UnitsHash.src/M000004.html +25 -0
- data/html/classes/Eymiha/UnitsHash.src/M000005.html +18 -0
- data/html/classes/Eymiha/UnitsHash.src/M000006.html +18 -0
- data/html/classes/Eymiha/UnitsHash.src/M000007.html +18 -0
- data/html/classes/Eymiha/UnitsHash.src/M000008.html +22 -0
- data/html/classes/Eymiha/UnitsHash.src/M000010.html +21 -0
- data/html/classes/Eymiha/UnitsHash.src/M000011.html +19 -0
- data/html/classes/Eymiha/UnitsHash.src/M000012.html +27 -0
- data/html/classes/Eymiha/UnitsHash.src/M000013.html +18 -0
- data/html/classes/Eymiha/UnitsMeasure.html +302 -0
- data/html/classes/Eymiha/UnitsMeasure.src/M000014.html +23 -0
- data/html/classes/Eymiha/UnitsMeasure.src/M000015.html +18 -0
- data/html/classes/Eymiha/UnitsMeasure.src/M000016.html +18 -0
- data/html/classes/Eymiha/UnitsMeasure.src/M000017.html +18 -0
- data/html/classes/Eymiha/UnitsMeasure.src/M000018.html +18 -0
- data/html/classes/Eymiha/UnitsMeasure.src/M000019.html +18 -0
- data/html/classes/Eymiha/UnitsMeasure.src/M000020.html +18 -0
- data/html/classes/Eymiha/UnitsSystem.html +196 -0
- data/html/classes/Eymiha/UnitsSystem.src/M000050.html +31 -0
- data/html/classes/Eymiha/UnitsSystem.src/M000051.html +18 -0
- data/html/classes/Eymiha/UnitsUnit.html +166 -0
- data/html/classes/Eymiha/UnitsUnit.src/M000049.html +18 -0
- data/html/classes/Eymiha.html +143 -0
- data/html/classes/Numeric.html +182 -0
- data/html/classes/Numeric.src/M000001.html +50 -0
- data/html/created.rid +1 -0
- data/html/files/lib/eymiha/units/definitions/area_rb.html +101 -0
- data/html/files/lib/eymiha/units/definitions/length_rb.html +101 -0
- data/html/files/lib/eymiha/units/definitions/mass_rb.html +101 -0
- data/html/files/lib/eymiha/units/definitions/measures_rb.html +113 -0
- data/html/files/lib/eymiha/units/definitions/time_rb.html +101 -0
- data/html/files/lib/eymiha/units/definitions/velocity_rb.html +101 -0
- data/html/files/lib/eymiha/units/definitions/volume_rb.html +101 -0
- data/html/files/lib/eymiha/units/numeric_rb.html +116 -0
- data/html/files/lib/eymiha/units/numeric_with_units_rb.html +109 -0
- data/html/files/lib/eymiha/units/object_rb.html +108 -0
- data/html/files/lib/eymiha/units/units_exception_rb.html +101 -0
- data/html/files/lib/eymiha/units/units_hash_rb.html +108 -0
- data/html/files/lib/eymiha/units/units_measure_rb.html +109 -0
- data/html/files/lib/eymiha/units/units_rb.html +115 -0
- data/html/files/lib/eymiha/units/units_system_rb.html +109 -0
- data/html/files/lib/eymiha/units/units_unit_rb.html +109 -0
- data/html/files/lib/eymiha/units_rb.html +115 -0
- data/html/fr_class_index.html +37 -0
- data/html/fr_file_index.html +43 -0
- data/html/fr_method_index.html +90 -0
- data/html/index.html +24 -0
- data/html/rdoc-style.css +208 -0
- data/lib/{units → eymiha/units}/definitions/area.rb +0 -0
- data/lib/{units → eymiha/units}/definitions/length.rb +0 -0
- data/lib/{units → eymiha/units}/definitions/mass.rb +0 -0
- data/lib/eymiha/units/definitions/measures.rb +6 -0
- data/lib/{units → eymiha/units}/definitions/time.rb +0 -0
- data/lib/{units → eymiha/units}/definitions/velocity.rb +0 -0
- data/lib/{units → eymiha/units}/definitions/volume.rb +0 -0
- data/lib/{units → eymiha/units}/numeric.rb +4 -3
- data/lib/eymiha/units/numeric_with_units.rb +640 -0
- data/lib/{units → eymiha/units}/object.rb +1 -1
- data/lib/eymiha/units/units.rb +234 -0
- data/lib/eymiha/units/units_exception.rb +18 -0
- data/lib/eymiha/units/units_hash.rb +118 -0
- data/lib/eymiha/units/units_measure.rb +95 -0
- data/lib/eymiha/units/units_system.rb +89 -0
- data/lib/eymiha/units/units_unit.rb +63 -0
- data/lib/eymiha/units.rb +4 -0
- data/test/tc_definitions.rb +1 -1
- data/test/tc_formatting.rb +2 -2
- data/test/tc_formatting_derived.rb +2 -2
- data/test/tc_measure_create.rb +2 -2
- data/test/tc_measure_derive.rb +2 -2
- data/test/tc_system_create.rb +2 -2
- data/test/tc_unit_ambiguity.rb +2 -2
- data/test/tc_unit_arithmetic.rb +2 -2
- data/test/tc_unit_create.rb +2 -2
- data/test/tc_unit_derive.rb +2 -2
- data/test/tc_unit_equality.rb +2 -2
- data/test/tc_unit_forward_reference.rb +2 -2
- data/test/tc_unit_greek.rb +2 -2
- data/test/tc_unit_hash.rb +2 -2
- data/test/tc_unit_identifiers.rb +2 -2
- data/test/tc_unit_rank.rb +2 -2
- data/test/tc_uses_1.rb +2 -2
- data/test/tc_uses_2.rb +2 -2
- metadata +190 -86
- data/lib/units/definitions/measures.rb +0 -6
- data/lib/units/numeric_with_units.rb +0 -635
- data/lib/units/units.rb +0 -229
- data/lib/units/units_exception.rb +0 -14
- data/lib/units/units_hash.rb +0 -112
- data/lib/units/units_measure.rb +0 -91
- data/lib/units/units_system.rb +0 -85
- data/lib/units/units_unit.rb +0 -60
- data/lib/units.rb +0 -4
@@ -0,0 +1,867 @@
|
|
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: Eymiha::NumericWithUnits</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">Eymiha::NumericWithUnits</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/lib/eymiha/units/numeric_with_units_rb.html">
|
59
|
+
lib/eymiha/units/numeric_with_units.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
|
+
<div id="description">
|
82
|
+
<p>
|
83
|
+
A <a href="NumericWithUnits.html">NumericWithUnits</a> is the intersection
|
84
|
+
of a <a href="../Numeric.html">Numeric</a> and a <a
|
85
|
+
href="UnitsHash.html">UnitsHash</a>.
|
86
|
+
</p>
|
87
|
+
<p>
|
88
|
+
Unit-sensitive coding is made much easier using an object that
|
89
|
+
transparently adds units to a common everyday Numerics. Everything that can
|
90
|
+
be done to a <a href="../Numeric.html">Numeric</a> is still there, but
|
91
|
+
explicit and implicit unit conversions are present in all of the
|
92
|
+
operations.
|
93
|
+
</p>
|
94
|
+
<p>
|
95
|
+
With this, numbers with units can be created easily. For example,
|
96
|
+
</p>
|
97
|
+
<pre>
|
98
|
+
2.feet # a length of 2 feet
|
99
|
+
5.inches^2 # an area of 5 square inches
|
100
|
+
44.5.ft/sec # a velocity of 44.5 feet per second
|
101
|
+
</pre>
|
102
|
+
<p>
|
103
|
+
This should provide a good starting point for using the <a
|
104
|
+
href="Units.html">Units</a> framework. Also pay attention to the examples
|
105
|
+
given in the method documentation; some of the dynamic features of the
|
106
|
+
framework are exposed in them.
|
107
|
+
</p>
|
108
|
+
|
109
|
+
</div>
|
110
|
+
|
111
|
+
|
112
|
+
</div>
|
113
|
+
|
114
|
+
<div id="method-list">
|
115
|
+
<h3 class="section-bar">Methods</h3>
|
116
|
+
|
117
|
+
<div class="name-list">
|
118
|
+
<a href="#M000035">%</a>
|
119
|
+
<a href="#M000031">*</a>
|
120
|
+
<a href="#M000033">**</a>
|
121
|
+
<a href="#M000029">+</a>
|
122
|
+
<a href="#M000027">+@</a>
|
123
|
+
<a href="#M000030">-</a>
|
124
|
+
<a href="#M000028">-@</a>
|
125
|
+
<a href="#M000032">/</a>
|
126
|
+
<a href="#M000024"><=></a>
|
127
|
+
<a href="#M000026">=~</a>
|
128
|
+
<a href="#M000034">^</a>
|
129
|
+
<a href="#M000039">align</a>
|
130
|
+
<a href="#M000025">approximately_equals?</a>
|
131
|
+
<a href="#M000043">convert</a>
|
132
|
+
<a href="#M000044">convert!</a>
|
133
|
+
<a href="#M000021">debug=</a>
|
134
|
+
<a href="#M000047">derived?</a>
|
135
|
+
<a href="#M000038">derived_align_type</a>
|
136
|
+
<a href="#M000037">derived_align_type=</a>
|
137
|
+
<a href="#M000040">extend</a>
|
138
|
+
<a href="#M000046">format</a>
|
139
|
+
<a href="#M000036">inv_mod</a>
|
140
|
+
<a href="#M000041">kind_of?</a>
|
141
|
+
<a href="#M000045">measure</a>
|
142
|
+
<a href="#M000022">new</a>
|
143
|
+
<a href="#M000048">reduce</a>
|
144
|
+
<a href="#M000023">to_s</a>
|
145
|
+
<a href="#M000042">unite</a>
|
146
|
+
</div>
|
147
|
+
</div>
|
148
|
+
|
149
|
+
</div>
|
150
|
+
|
151
|
+
|
152
|
+
<!-- if includes -->
|
153
|
+
<div id="includes">
|
154
|
+
<h3 class="section-bar">Included Modules</h3>
|
155
|
+
|
156
|
+
<div id="includes-list">
|
157
|
+
<span class="include-name">Comparable</span>
|
158
|
+
</div>
|
159
|
+
</div>
|
160
|
+
|
161
|
+
<div id="section">
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
<div id="aliases-list">
|
166
|
+
<h3 class="section-bar">External Aliases</h3>
|
167
|
+
|
168
|
+
<div class="name-list">
|
169
|
+
<table summary="aliases">
|
170
|
+
<tr class="top-aligned-row context-row">
|
171
|
+
<td class="context-item-name">kind_of?</td>
|
172
|
+
<td>-></td>
|
173
|
+
<td class="context-item-value">old_kind_of?</td>
|
174
|
+
</tr>
|
175
|
+
</table>
|
176
|
+
</div>
|
177
|
+
</div>
|
178
|
+
|
179
|
+
|
180
|
+
<div id="attribute-list">
|
181
|
+
<h3 class="section-bar">Attributes</h3>
|
182
|
+
|
183
|
+
<div class="name-list">
|
184
|
+
<table>
|
185
|
+
<tr class="top-aligned-row context-row">
|
186
|
+
<td class="context-item-name">numeric</td>
|
187
|
+
<td class="context-item-value"> [RW] </td>
|
188
|
+
<td class="context-item-desc">
|
189
|
+
A <a href="../Numeric.html">Numeric</a> containing the numeric part of the
|
190
|
+
instance
|
191
|
+
|
192
|
+
</td>
|
193
|
+
</tr>
|
194
|
+
<tr class="top-aligned-row context-row">
|
195
|
+
<td class="context-item-name">unit</td>
|
196
|
+
<td class="context-item-value"> [RW] </td>
|
197
|
+
<td class="context-item-desc">
|
198
|
+
A <a href="UnitsHash.html">UnitsHash</a> containing the units part of the
|
199
|
+
instance
|
200
|
+
|
201
|
+
</td>
|
202
|
+
</tr>
|
203
|
+
</table>
|
204
|
+
</div>
|
205
|
+
</div>
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
<!-- if method_list -->
|
210
|
+
<div id="methods">
|
211
|
+
<h3 class="section-bar">Public Class methods</h3>
|
212
|
+
|
213
|
+
<div id="method-M000021" class="method-detail">
|
214
|
+
<a name="M000021"></a>
|
215
|
+
|
216
|
+
<div class="method-heading">
|
217
|
+
<a href="NumericWithUnits.src/M000021.html" target="Code" class="method-signature"
|
218
|
+
onclick="popupCode('NumericWithUnits.src/M000021.html');return false;">
|
219
|
+
<span class="method-name">debug=</span><span class="method-args">(value)</span>
|
220
|
+
</a>
|
221
|
+
</div>
|
222
|
+
|
223
|
+
<div class="method-description">
|
224
|
+
</div>
|
225
|
+
</div>
|
226
|
+
|
227
|
+
<div id="method-M000038" class="method-detail">
|
228
|
+
<a name="M000038"></a>
|
229
|
+
|
230
|
+
<div class="method-heading">
|
231
|
+
<a href="NumericWithUnits.src/M000038.html" target="Code" class="method-signature"
|
232
|
+
onclick="popupCode('NumericWithUnits.src/M000038.html');return false;">
|
233
|
+
<span class="method-name">derived_align_type</span><span class="method-args">()</span>
|
234
|
+
</a>
|
235
|
+
</div>
|
236
|
+
|
237
|
+
<div class="method-description">
|
238
|
+
<p>
|
239
|
+
Returns the type of exponentiation merging during alignment.
|
240
|
+
</p>
|
241
|
+
<ul>
|
242
|
+
<li>:whole_powers require exponents to have integer values
|
243
|
+
|
244
|
+
</li>
|
245
|
+
<li>:fractional_powers allow exponents to have rational values
|
246
|
+
|
247
|
+
</li>
|
248
|
+
</ul>
|
249
|
+
</div>
|
250
|
+
</div>
|
251
|
+
|
252
|
+
<div id="method-M000037" class="method-detail">
|
253
|
+
<a name="M000037"></a>
|
254
|
+
|
255
|
+
<div class="method-heading">
|
256
|
+
<a href="NumericWithUnits.src/M000037.html" target="Code" class="method-signature"
|
257
|
+
onclick="popupCode('NumericWithUnits.src/M000037.html');return false;">
|
258
|
+
<span class="method-name">derived_align_type=</span><span class="method-args">(type)</span>
|
259
|
+
</a>
|
260
|
+
</div>
|
261
|
+
|
262
|
+
<div class="method-description">
|
263
|
+
<p>
|
264
|
+
Sets and returns the type of exponentiation merging during alignment.
|
265
|
+
</p>
|
266
|
+
</div>
|
267
|
+
</div>
|
268
|
+
|
269
|
+
<div id="method-M000022" class="method-detail">
|
270
|
+
<a name="M000022"></a>
|
271
|
+
|
272
|
+
<div class="method-heading">
|
273
|
+
<a href="NumericWithUnits.src/M000022.html" target="Code" class="method-signature"
|
274
|
+
onclick="popupCode('NumericWithUnits.src/M000022.html');return false;">
|
275
|
+
<span class="method-name">new</span><span class="method-args">(numeric,unit,power=1)</span>
|
276
|
+
</a>
|
277
|
+
</div>
|
278
|
+
|
279
|
+
<div class="method-description">
|
280
|
+
<p>
|
281
|
+
Returns a <a href="NumericWithUnits.html#M000022">new</a> <a
|
282
|
+
href="NumericWithUnits.html">NumericWithUnits</a> instance whose numeric
|
283
|
+
part is set to numeric and whose units part is set to a units hash for the
|
284
|
+
unit raised to the provided power.
|
285
|
+
</p>
|
286
|
+
</div>
|
287
|
+
</div>
|
288
|
+
|
289
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
290
|
+
|
291
|
+
<div id="method-M000035" class="method-detail">
|
292
|
+
<a name="M000035"></a>
|
293
|
+
|
294
|
+
<div class="method-heading">
|
295
|
+
<a href="NumericWithUnits.src/M000035.html" target="Code" class="method-signature"
|
296
|
+
onclick="popupCode('NumericWithUnits.src/M000035.html');return false;">
|
297
|
+
<span class="method-name">%</span><span class="method-args">(value)</span>
|
298
|
+
</a>
|
299
|
+
</div>
|
300
|
+
|
301
|
+
<div class="method-description">
|
302
|
+
<p>
|
303
|
+
Returns a <a href="NumericWithUnits.html#M000022">new</a> <a
|
304
|
+
href="NumericWithUnits.html">NumericWithUnits</a> containing the numeric
|
305
|
+
part of the instance modulo the numeric part of the value, with the units
|
306
|
+
part equal to the instance‘s units part. If the value is a <a
|
307
|
+
href="../Numeric.html">Numeric</a>, the units are assumed to match. If the
|
308
|
+
UnitsMeasures don‘t match, a <a
|
309
|
+
href="UnitsException.html">UnitsException</a> is raised.
|
310
|
+
</p>
|
311
|
+
<pre>
|
312
|
+
30.in % 2.ft # 0.5 feet
|
313
|
+
5.in % 2.3 # 0.4 inches
|
314
|
+
5.in % 2.sec # UnitsException
|
315
|
+
</pre>
|
316
|
+
</div>
|
317
|
+
</div>
|
318
|
+
|
319
|
+
<div id="method-M000031" class="method-detail">
|
320
|
+
<a name="M000031"></a>
|
321
|
+
|
322
|
+
<div class="method-heading">
|
323
|
+
<a href="NumericWithUnits.src/M000031.html" target="Code" class="method-signature"
|
324
|
+
onclick="popupCode('NumericWithUnits.src/M000031.html');return false;">
|
325
|
+
<span class="method-name">*</span><span class="method-args">(value)</span>
|
326
|
+
</a>
|
327
|
+
</div>
|
328
|
+
|
329
|
+
<div class="method-description">
|
330
|
+
<p>
|
331
|
+
Returns a <a href="NumericWithUnits.html#M000022">new</a> <a
|
332
|
+
href="NumericWithUnits.html">NumericWithUnits</a> containing the product of
|
333
|
+
the instance and the value. The units of the two factors are merged. If the
|
334
|
+
value is not a <a href="../Numeric.html">Numeric</a> nor <a
|
335
|
+
href="NumericWithUnits.html">NumericWithUnits</a>, a <a
|
336
|
+
href="UnitsException.html">UnitsException</a> is thrown.
|
337
|
+
</p>
|
338
|
+
<pre>
|
339
|
+
6.in * 2.ft # 1 foot^2
|
340
|
+
6.in * 2 # 12 inches
|
341
|
+
6.in * 2.sec # 12 ft sec
|
342
|
+
6.in * "hello" # UnitsException
|
343
|
+
</pre>
|
344
|
+
</div>
|
345
|
+
</div>
|
346
|
+
|
347
|
+
<div id="method-M000033" class="method-detail">
|
348
|
+
<a name="M000033"></a>
|
349
|
+
|
350
|
+
<div class="method-heading">
|
351
|
+
<a href="NumericWithUnits.src/M000033.html" target="Code" class="method-signature"
|
352
|
+
onclick="popupCode('NumericWithUnits.src/M000033.html');return false;">
|
353
|
+
<span class="method-name">**</span><span class="method-args">(value)</span>
|
354
|
+
</a>
|
355
|
+
</div>
|
356
|
+
|
357
|
+
<div class="method-description">
|
358
|
+
<p>
|
359
|
+
Returns a <a href="NumericWithUnits.html#M000022">new</a> <a
|
360
|
+
href="NumericWithUnits.html">NumericWithUnits</a> containing the numeric
|
361
|
+
and units parts of the instance both raised to the valueth power. If the
|
362
|
+
value is not a <a href="../Numeric.html">Numeric</a>, a <a
|
363
|
+
href="UnitsException.html">UnitsException</a> is thrown.
|
364
|
+
</p>
|
365
|
+
<pre>
|
366
|
+
6.in ** 3 # 216 in^3
|
367
|
+
6.in ** 3.in # UnitsException
|
368
|
+
</pre>
|
369
|
+
</div>
|
370
|
+
</div>
|
371
|
+
|
372
|
+
<div id="method-M000029" class="method-detail">
|
373
|
+
<a name="M000029"></a>
|
374
|
+
|
375
|
+
<div class="method-heading">
|
376
|
+
<a href="NumericWithUnits.src/M000029.html" target="Code" class="method-signature"
|
377
|
+
onclick="popupCode('NumericWithUnits.src/M000029.html');return false;">
|
378
|
+
<span class="method-name">+</span><span class="method-args">(value)</span>
|
379
|
+
</a>
|
380
|
+
</div>
|
381
|
+
|
382
|
+
<div class="method-description">
|
383
|
+
<p>
|
384
|
+
Returns a <a href="NumericWithUnits.html#M000022">new</a> <a
|
385
|
+
href="NumericWithUnits.html">NumericWithUnits</a> containing the sum of the
|
386
|
+
instance and the value. If the value is a <a
|
387
|
+
href="../Numeric.html">Numeric</a>, the units are assumed to match. If the
|
388
|
+
UnitsMeasures don‘t match, a <a
|
389
|
+
href="UnitsException.html">UnitsException</a> is raised.
|
390
|
+
</p>
|
391
|
+
<pre>
|
392
|
+
6.inches + 1.foot # 18 inches
|
393
|
+
6.inches + 1 # 7 inches
|
394
|
+
6.inches + 1.sec # UnitsException
|
395
|
+
</pre>
|
396
|
+
</div>
|
397
|
+
</div>
|
398
|
+
|
399
|
+
<div id="method-M000027" class="method-detail">
|
400
|
+
<a name="M000027"></a>
|
401
|
+
|
402
|
+
<div class="method-heading">
|
403
|
+
<a href="NumericWithUnits.src/M000027.html" target="Code" class="method-signature"
|
404
|
+
onclick="popupCode('NumericWithUnits.src/M000027.html');return false;">
|
405
|
+
<span class="method-name">+@</span><span class="method-args">()</span>
|
406
|
+
</a>
|
407
|
+
</div>
|
408
|
+
|
409
|
+
<div class="method-description">
|
410
|
+
<p>
|
411
|
+
Unary plus returns a copy of the instance.
|
412
|
+
</p>
|
413
|
+
</div>
|
414
|
+
</div>
|
415
|
+
|
416
|
+
<div id="method-M000030" class="method-detail">
|
417
|
+
<a name="M000030"></a>
|
418
|
+
|
419
|
+
<div class="method-heading">
|
420
|
+
<a href="NumericWithUnits.src/M000030.html" target="Code" class="method-signature"
|
421
|
+
onclick="popupCode('NumericWithUnits.src/M000030.html');return false;">
|
422
|
+
<span class="method-name">-</span><span class="method-args">(value)</span>
|
423
|
+
</a>
|
424
|
+
</div>
|
425
|
+
|
426
|
+
<div class="method-description">
|
427
|
+
<p>
|
428
|
+
Returns a <a href="NumericWithUnits.html#M000022">new</a> <a
|
429
|
+
href="NumericWithUnits.html">NumericWithUnits</a> containing the difference
|
430
|
+
between the instance and the value. If the value is a <a
|
431
|
+
href="../Numeric.html">Numeric</a>, the units are assumed to match. If the
|
432
|
+
UnitsMeasures don‘t match, a <a
|
433
|
+
href="UnitsException.html">UnitsException</a> is raised.
|
434
|
+
</p>
|
435
|
+
<pre>
|
436
|
+
6.inches - 1.foot # -6 inches
|
437
|
+
6.inches - 1 # 5 inches
|
438
|
+
6.inches - 1.sec # UnitsException
|
439
|
+
</pre>
|
440
|
+
</div>
|
441
|
+
</div>
|
442
|
+
|
443
|
+
<div id="method-M000028" class="method-detail">
|
444
|
+
<a name="M000028"></a>
|
445
|
+
|
446
|
+
<div class="method-heading">
|
447
|
+
<a href="NumericWithUnits.src/M000028.html" target="Code" class="method-signature"
|
448
|
+
onclick="popupCode('NumericWithUnits.src/M000028.html');return false;">
|
449
|
+
<span class="method-name">-@</span><span class="method-args">()</span>
|
450
|
+
</a>
|
451
|
+
</div>
|
452
|
+
|
453
|
+
<div class="method-description">
|
454
|
+
<p>
|
455
|
+
Unary minus returns a copy of the instance with its numeric part negated.
|
456
|
+
</p>
|
457
|
+
</div>
|
458
|
+
</div>
|
459
|
+
|
460
|
+
<div id="method-M000032" class="method-detail">
|
461
|
+
<a name="M000032"></a>
|
462
|
+
|
463
|
+
<div class="method-heading">
|
464
|
+
<a href="NumericWithUnits.src/M000032.html" target="Code" class="method-signature"
|
465
|
+
onclick="popupCode('NumericWithUnits.src/M000032.html');return false;">
|
466
|
+
<span class="method-name">/</span><span class="method-args">(value)</span>
|
467
|
+
</a>
|
468
|
+
</div>
|
469
|
+
|
470
|
+
<div class="method-description">
|
471
|
+
<p>
|
472
|
+
Returns a <a href="NumericWithUnits.html#M000022">new</a> <a
|
473
|
+
href="NumericWithUnits.html">NumericWithUnits</a> containing the value of
|
474
|
+
the instance divided by the value. The units of the result are the units of
|
475
|
+
the instance merged with the recipricol of the units of the value. If the
|
476
|
+
value is neither a <a href="../Numeric.html">Numeric</a> nor <a
|
477
|
+
href="NumericWithUnits.html">NumericWithUnits</a>, a <a
|
478
|
+
href="UnitsException.html">UnitsException</a> is thrown.
|
479
|
+
</p>
|
480
|
+
<pre>
|
481
|
+
6.in / 2.ft # 0.25
|
482
|
+
6.in / 2 # 3 inches
|
483
|
+
6.in / 2.sec # 3 ft / sec
|
484
|
+
6.in / "hello" # UnitsException
|
485
|
+
</pre>
|
486
|
+
</div>
|
487
|
+
</div>
|
488
|
+
|
489
|
+
<div id="method-M000024" class="method-detail">
|
490
|
+
<a name="M000024"></a>
|
491
|
+
|
492
|
+
<div class="method-heading">
|
493
|
+
<a href="NumericWithUnits.src/M000024.html" target="Code" class="method-signature"
|
494
|
+
onclick="popupCode('NumericWithUnits.src/M000024.html');return false;">
|
495
|
+
<span class="method-name"><=></span><span class="method-args">(value)</span>
|
496
|
+
</a>
|
497
|
+
</div>
|
498
|
+
|
499
|
+
<div class="method-description">
|
500
|
+
<p>
|
501
|
+
Compares the numeric and units parts of the instance with the value. If the
|
502
|
+
value is a <a href="../Numeric.html">Numeric</a>, the units are assumed to
|
503
|
+
match. If the UnitsMeasures don‘t match, a <a
|
504
|
+
href="UnitsException.html">UnitsException</a> is raised.
|
505
|
+
</p>
|
506
|
+
<pre>
|
507
|
+
2.ft <=> 1.yd # -1
|
508
|
+
3.ft <=> 1.yd # 0
|
509
|
+
4.ft <=> 1.yd # 1
|
510
|
+
4.ft <=> 3.5 # 1
|
511
|
+
4.ft <=> 2.minutes # UnitsException
|
512
|
+
</pre>
|
513
|
+
</div>
|
514
|
+
</div>
|
515
|
+
|
516
|
+
<div id="method-M000026" class="method-detail">
|
517
|
+
<a name="M000026"></a>
|
518
|
+
|
519
|
+
<div class="method-heading">
|
520
|
+
<span class="method-name">=~</span><span class="method-args">(value,epsilon=Numeric.epsilon)</span>
|
521
|
+
</div>
|
522
|
+
|
523
|
+
<div class="method-description">
|
524
|
+
<p>
|
525
|
+
Alias for approximately_equals?
|
526
|
+
</p>
|
527
|
+
</div>
|
528
|
+
</div>
|
529
|
+
|
530
|
+
<div id="method-M000034" class="method-detail">
|
531
|
+
<a name="M000034"></a>
|
532
|
+
|
533
|
+
<div class="method-heading">
|
534
|
+
<a href="NumericWithUnits.src/M000034.html" target="Code" class="method-signature"
|
535
|
+
onclick="popupCode('NumericWithUnits.src/M000034.html');return false;">
|
536
|
+
<span class="method-name">^</span><span class="method-args">(value)</span>
|
537
|
+
</a>
|
538
|
+
</div>
|
539
|
+
|
540
|
+
<div class="method-description">
|
541
|
+
<p>
|
542
|
+
Returns a <a href="NumericWithUnits.html#M000022">new</a> <a
|
543
|
+
href="NumericWithUnits.html">NumericWithUnits</a> containing the numeric
|
544
|
+
and units parts of the instance with just the units raised to the valueth
|
545
|
+
power. If the value is not a <a href="../Numeric.html">Numeric</a>, a <a
|
546
|
+
href="UnitsException.html">UnitsException</a> is thrown.
|
547
|
+
</p>
|
548
|
+
<pre>
|
549
|
+
6.in ^ 3 # 6 in^3
|
550
|
+
6.in ^ 3.in # UnitsException
|
551
|
+
</pre>
|
552
|
+
</div>
|
553
|
+
</div>
|
554
|
+
|
555
|
+
<div id="method-M000039" class="method-detail">
|
556
|
+
<a name="M000039"></a>
|
557
|
+
|
558
|
+
<div class="method-heading">
|
559
|
+
<a href="NumericWithUnits.src/M000039.html" target="Code" class="method-signature"
|
560
|
+
onclick="popupCode('NumericWithUnits.src/M000039.html');return false;">
|
561
|
+
<span class="method-name">align</span><span class="method-args">(target,all=true,type=@@derived_align_type)</span>
|
562
|
+
</a>
|
563
|
+
</div>
|
564
|
+
|
565
|
+
<div class="method-description">
|
566
|
+
<p>
|
567
|
+
Returns a <a href="NumericWithUnits.html#M000022">new</a> <a
|
568
|
+
href="NumericWithUnits.html">NumericWithUnits</a> whose value is equivalent
|
569
|
+
to that of the instance, but whose units are aligned to the target,
|
570
|
+
according to the value of <a
|
571
|
+
href="NumericWithUnits.html#M000038">derived_align_type</a>. If all is
|
572
|
+
true, then the <a href="UnitsMeasure.html">UnitsMeasure</a> of the instance
|
573
|
+
and the target must match exactly, or else a <a
|
574
|
+
href="UnitsException.html">UnitsException</a> is raised.
|
575
|
+
</p>
|
576
|
+
<pre>
|
577
|
+
(80.miles_per_hour).align(1.min,false) # 1.3333333 mi / min
|
578
|
+
</pre>
|
579
|
+
</div>
|
580
|
+
</div>
|
581
|
+
|
582
|
+
<div id="method-M000025" class="method-detail">
|
583
|
+
<a name="M000025"></a>
|
584
|
+
|
585
|
+
<div class="method-heading">
|
586
|
+
<a href="NumericWithUnits.src/M000025.html" target="Code" class="method-signature"
|
587
|
+
onclick="popupCode('NumericWithUnits.src/M000025.html');return false;">
|
588
|
+
<span class="method-name">approximately_equals?</span><span class="method-args">(value,epsilon=Numeric.epsilon)</span>
|
589
|
+
</a>
|
590
|
+
</div>
|
591
|
+
|
592
|
+
<div class="method-description">
|
593
|
+
<p>
|
594
|
+
Returns true if the value and the instance are within a distance epsilon of
|
595
|
+
each other. If the value is a <a href="../Numeric.html">Numeric</a>, the
|
596
|
+
units are assumed to match. If the UnitsMeasures don‘t match, a <a
|
597
|
+
href="UnitsException.html">UnitsException</a> is raised.
|
598
|
+
</p>
|
599
|
+
<pre>
|
600
|
+
1.ft.approximately_equals? 0.33.yd # false
|
601
|
+
1.ft.approximately_equals? 0.333333.yd # true
|
602
|
+
</pre>
|
603
|
+
</div>
|
604
|
+
</div>
|
605
|
+
|
606
|
+
<div id="method-M000043" class="method-detail">
|
607
|
+
<a name="M000043"></a>
|
608
|
+
|
609
|
+
<div class="method-heading">
|
610
|
+
<a href="NumericWithUnits.src/M000043.html" target="Code" class="method-signature"
|
611
|
+
onclick="popupCode('NumericWithUnits.src/M000043.html');return false;">
|
612
|
+
<span class="method-name">convert</span><span class="method-args">(target_units=nil)</span>
|
613
|
+
</a>
|
614
|
+
</div>
|
615
|
+
|
616
|
+
<div class="method-description">
|
617
|
+
<p>
|
618
|
+
Returns a copy of the instance converted to the target_units. Note that the
|
619
|
+
conversion is only with respect to the UnitsMeasures of the target_units -
|
620
|
+
the remainder of the units will remain unconverted.
|
621
|
+
</p>
|
622
|
+
</div>
|
623
|
+
</div>
|
624
|
+
|
625
|
+
<div id="method-M000044" class="method-detail">
|
626
|
+
<a name="M000044"></a>
|
627
|
+
|
628
|
+
<div class="method-heading">
|
629
|
+
<a href="NumericWithUnits.src/M000044.html" target="Code" class="method-signature"
|
630
|
+
onclick="popupCode('NumericWithUnits.src/M000044.html');return false;">
|
631
|
+
<span class="method-name">convert!</span><span class="method-args">(target_units=nil)</span>
|
632
|
+
</a>
|
633
|
+
</div>
|
634
|
+
|
635
|
+
<div class="method-description">
|
636
|
+
<p>
|
637
|
+
Converts the instance itself.
|
638
|
+
</p>
|
639
|
+
</div>
|
640
|
+
</div>
|
641
|
+
|
642
|
+
<div id="method-M000047" class="method-detail">
|
643
|
+
<a name="M000047"></a>
|
644
|
+
|
645
|
+
<div class="method-heading">
|
646
|
+
<a href="NumericWithUnits.src/M000047.html" target="Code" class="method-signature"
|
647
|
+
onclick="popupCode('NumericWithUnits.src/M000047.html');return false;">
|
648
|
+
<span class="method-name">derived?</span><span class="method-args">()</span>
|
649
|
+
</a>
|
650
|
+
</div>
|
651
|
+
|
652
|
+
<div class="method-description">
|
653
|
+
<p>
|
654
|
+
Returns true if a component of unit part of the instance has a derived <a
|
655
|
+
href="UnitsMeasure.html">UnitsMeasure</a>.
|
656
|
+
</p>
|
657
|
+
</div>
|
658
|
+
</div>
|
659
|
+
|
660
|
+
<div id="method-M000040" class="method-detail">
|
661
|
+
<a name="M000040"></a>
|
662
|
+
|
663
|
+
<div class="method-heading">
|
664
|
+
<a href="NumericWithUnits.src/M000040.html" target="Code" class="method-signature"
|
665
|
+
onclick="popupCode('NumericWithUnits.src/M000040.html');return false;">
|
666
|
+
<span class="method-name">extend</span><span class="method-args">(units,power)</span>
|
667
|
+
</a>
|
668
|
+
</div>
|
669
|
+
|
670
|
+
<div class="method-description">
|
671
|
+
<p>
|
672
|
+
Returns a <a href="NumericWithUnits.html#M000022">new</a> <a
|
673
|
+
href="NumericWithUnits.html">NumericWithUnits</a> whose value is extended
|
674
|
+
by raising it to the power, or by multiplying it by units raised to the
|
675
|
+
power.
|
676
|
+
</p>
|
677
|
+
<pre>
|
678
|
+
7.miles.extend(nil,2) # 49 mi^2
|
679
|
+
5.feet.extend(10.ft,2) # 500 ft^3
|
680
|
+
</pre>
|
681
|
+
</div>
|
682
|
+
</div>
|
683
|
+
|
684
|
+
<div id="method-M000046" class="method-detail">
|
685
|
+
<a name="M000046"></a>
|
686
|
+
|
687
|
+
<div class="method-heading">
|
688
|
+
<a href="NumericWithUnits.src/M000046.html" target="Code" class="method-signature"
|
689
|
+
onclick="popupCode('NumericWithUnits.src/M000046.html');return false;">
|
690
|
+
<span class="method-name">format</span><span class="method-args">(name=nil)</span>
|
691
|
+
</a>
|
692
|
+
</div>
|
693
|
+
|
694
|
+
<div class="method-description">
|
695
|
+
<p>
|
696
|
+
Returns a String formatted using the named <a
|
697
|
+
href="NumericWithUnits.html#M000046">format</a> defined in the
|
698
|
+
instance‘s <a href="NumericWithUnits.html#M000045">measure</a>.
|
699
|
+
Raises a <a href="UnitsException.html">UnitsException</a> if either the
|
700
|
+
unit part of the instance has no defined <a
|
701
|
+
href="UnitsMeasure.html">UnitsMeasure</a> or a <a
|
702
|
+
href="NumericWithUnits.html#M000046">format</a> with the given name does
|
703
|
+
not exist in that <a href="UnitsMeasure.html">UnitsMeasure</a>.
|
704
|
+
</p>
|
705
|
+
</div>
|
706
|
+
</div>
|
707
|
+
|
708
|
+
<div id="method-M000036" class="method-detail">
|
709
|
+
<a name="M000036"></a>
|
710
|
+
|
711
|
+
<div class="method-heading">
|
712
|
+
<a href="NumericWithUnits.src/M000036.html" target="Code" class="method-signature"
|
713
|
+
onclick="popupCode('NumericWithUnits.src/M000036.html');return false;">
|
714
|
+
<span class="method-name">inv_mod</span><span class="method-args">(value)</span>
|
715
|
+
</a>
|
716
|
+
</div>
|
717
|
+
|
718
|
+
<div class="method-description">
|
719
|
+
<p>
|
720
|
+
Returns a <a href="NumericWithUnits.html#M000022">new</a> <a
|
721
|
+
href="NumericWithUnits.html">NumericWithUnits</a> containing the numeric
|
722
|
+
part of the value modulo the numeric part of the instance, with the units
|
723
|
+
part equal to the instance‘s units part. If the value is a <a
|
724
|
+
href="../Numeric.html">Numeric</a>, the units are assumed to match. If the
|
725
|
+
UnitsMeasures don‘t match, a <a
|
726
|
+
href="UnitsException.html">UnitsException</a> is raised.
|
727
|
+
</p>
|
728
|
+
<pre>
|
729
|
+
30.in % 2.ft # 24 inches
|
730
|
+
5.in % 2.3 # 2.3 inches
|
731
|
+
5.in % 2.sec # UnitsException
|
732
|
+
</pre>
|
733
|
+
</div>
|
734
|
+
</div>
|
735
|
+
|
736
|
+
<div id="method-M000041" class="method-detail">
|
737
|
+
<a name="M000041"></a>
|
738
|
+
|
739
|
+
<div class="method-heading">
|
740
|
+
<a href="NumericWithUnits.src/M000041.html" target="Code" class="method-signature"
|
741
|
+
onclick="popupCode('NumericWithUnits.src/M000041.html');return false;">
|
742
|
+
<span class="method-name">kind_of?</span><span class="method-args">(klass)</span>
|
743
|
+
</a>
|
744
|
+
</div>
|
745
|
+
|
746
|
+
<div class="method-description">
|
747
|
+
<p>
|
748
|
+
Returns true if the instance or it‘s numeric part is a kind of klass.
|
749
|
+
</p>
|
750
|
+
<pre>
|
751
|
+
28.feet.kind_of? String # false
|
752
|
+
28.feet.kind_of? NumericWithUnits # true
|
753
|
+
28.feet.kind_of? Numeric # true
|
754
|
+
28.feet.kind_of? Integer # true
|
755
|
+
28.feet.kind_of? Float # false
|
756
|
+
28.0.feet.kind_of? Float # true
|
757
|
+
</pre>
|
758
|
+
<p>
|
759
|
+
Note while <a href="NumericWithUnits.html">NumericWithUnits</a> actually
|
760
|
+
descends from Object, it acts as if it is inherited from the class of the
|
761
|
+
numeric part of the instance, since it forwards any unknown method calls to
|
762
|
+
it. In this way the duck really is a duck.
|
763
|
+
</p>
|
764
|
+
</div>
|
765
|
+
</div>
|
766
|
+
|
767
|
+
<div id="method-M000045" class="method-detail">
|
768
|
+
<a name="M000045"></a>
|
769
|
+
|
770
|
+
<div class="method-heading">
|
771
|
+
<a href="NumericWithUnits.src/M000045.html" target="Code" class="method-signature"
|
772
|
+
onclick="popupCode('NumericWithUnits.src/M000045.html');return false;">
|
773
|
+
<span class="method-name">measure</span><span class="method-args">()</span>
|
774
|
+
</a>
|
775
|
+
</div>
|
776
|
+
|
777
|
+
<div class="method-description">
|
778
|
+
<p>
|
779
|
+
Returns the UnitsMeasures in the units part of the instance.
|
780
|
+
</p>
|
781
|
+
</div>
|
782
|
+
</div>
|
783
|
+
|
784
|
+
<div id="method-M000048" class="method-detail">
|
785
|
+
<a name="M000048"></a>
|
786
|
+
|
787
|
+
<div class="method-heading">
|
788
|
+
<a href="NumericWithUnits.src/M000048.html" target="Code" class="method-signature"
|
789
|
+
onclick="popupCode('NumericWithUnits.src/M000048.html');return false;">
|
790
|
+
<span class="method-name">reduce</span><span class="method-args">()</span>
|
791
|
+
</a>
|
792
|
+
</div>
|
793
|
+
|
794
|
+
<div class="method-description">
|
795
|
+
<p>
|
796
|
+
Return a <a href="NumericWithUnits.html#M000022">new</a> <a
|
797
|
+
href="NumericWithUnits.html">NumericWithUnits</a> that is equivalent to the
|
798
|
+
instance but whose unit contains no derived UnitMeasures.
|
799
|
+
</p>
|
800
|
+
</div>
|
801
|
+
</div>
|
802
|
+
|
803
|
+
<div id="method-M000023" class="method-detail">
|
804
|
+
<a name="M000023"></a>
|
805
|
+
|
806
|
+
<div class="method-heading">
|
807
|
+
<a href="NumericWithUnits.src/M000023.html" target="Code" class="method-signature"
|
808
|
+
onclick="popupCode('NumericWithUnits.src/M000023.html');return false;">
|
809
|
+
<span class="method-name">to_s</span><span class="method-args">(format = nil)</span>
|
810
|
+
</a>
|
811
|
+
</div>
|
812
|
+
|
813
|
+
<div class="method-description">
|
814
|
+
<p>
|
815
|
+
Returns a String representation of the instance, using the named <a
|
816
|
+
href="NumericWithUnits.html#M000046">format</a> if provided.
|
817
|
+
</p>
|
818
|
+
<pre>
|
819
|
+
15.5.minutes.to_s # 15.5 minutes
|
820
|
+
15.5.minutes.to_seconds.to_s # 930.0 seconds
|
821
|
+
15.5.minutes.in_seconds.to_s # 930.0 seconds
|
822
|
+
15.5.minutes.seconds.to_s # 930.0 seconds
|
823
|
+
(15.5.minutes+1).seconds.to_s # 990.0 seconds
|
824
|
+
(15.5.minutes.seconds+1).to_s # 931.0 seconds
|
825
|
+
10.feet_per_minute.to_s # 10 ft / min
|
826
|
+
seconds_per_hour.to_s # 3600.0
|
827
|
+
14.5.inches.to_s(:feet_inches_and_32s) # "1 foot 2-16/32 inches"
|
828
|
+
</pre>
|
829
|
+
</div>
|
830
|
+
</div>
|
831
|
+
|
832
|
+
<div id="method-M000042" class="method-detail">
|
833
|
+
<a name="M000042"></a>
|
834
|
+
|
835
|
+
<div class="method-heading">
|
836
|
+
<a href="NumericWithUnits.src/M000042.html" target="Code" class="method-signature"
|
837
|
+
onclick="popupCode('NumericWithUnits.src/M000042.html');return false;">
|
838
|
+
<span class="method-name">unite</span><span class="method-args">(target_unit=nil,power=1,measure=nil)</span>
|
839
|
+
</a>
|
840
|
+
</div>
|
841
|
+
|
842
|
+
<div class="method-description">
|
843
|
+
<p>
|
844
|
+
Returns a <a href="NumericWithUnits.html#M000022">new</a> <a
|
845
|
+
href="NumericWithUnits.html">NumericWithUnits</a> whose numeric part is the
|
846
|
+
target of the <a href="../Numeric.html">Numeric</a>‘s <a
|
847
|
+
href="NumericWithUnits.html#M000042">unite</a> method.
|
848
|
+
</p>
|
849
|
+
<pre>
|
850
|
+
28.ft^2.unite("seconds") # 28 seconds
|
851
|
+
</pre>
|
852
|
+
</div>
|
853
|
+
</div>
|
854
|
+
|
855
|
+
|
856
|
+
</div>
|
857
|
+
|
858
|
+
|
859
|
+
</div>
|
860
|
+
|
861
|
+
|
862
|
+
<div id="validator-badges">
|
863
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
864
|
+
</div>
|
865
|
+
|
866
|
+
</body>
|
867
|
+
</html>
|