temperature 1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/COPYING +21 -0
- data/README +45 -0
- data/Rakefile +133 -0
- data/docs/temperature/classes/Numeric.html +619 -0
- data/docs/temperature/classes/String.html +167 -0
- data/docs/temperature/created.rid +1 -0
- data/docs/temperature/files/COPYING.html +133 -0
- data/docs/temperature/files/README.html +156 -0
- data/docs/temperature/files/lib/temperature_rb.html +123 -0
- data/docs/temperature/fr_class_index.html +28 -0
- data/docs/temperature/fr_file_index.html +29 -0
- data/docs/temperature/fr_method_index.html +42 -0
- data/docs/temperature/index.html +24 -0
- data/docs/temperature/rdoc-style.css +208 -0
- data/lib/temperature.rb +174 -0
- data/test/convert_test.rb +69 -0
- data/test/coverage/index.html +100 -0
- data/test/coverage/lib-temperature_rb.html +300 -0
- data/test/dewpoint_test.rb +16 -0
- data/test/num_test.rb +32 -0
- metadata +76 -0
data/lib/temperature.rb
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
# Temperature works as a mixin on both the Numeric and String classes.
|
2
|
+
# The idea is to make manipulating temperatures as simple and natural
|
3
|
+
# as possible. If units are not specified, they are assume to be in
|
4
|
+
# degrees 'F'. Yes, I realize this is US centric, but that's where I
|
5
|
+
# live. In the future I'd like to auto detect that base on locale.
|
6
|
+
#
|
7
|
+
# Example use:
|
8
|
+
#
|
9
|
+
# freezing_in_C = 32.to_C
|
10
|
+
#
|
11
|
+
# num = 0
|
12
|
+
# num.units = "C"
|
13
|
+
# freezing_in_F = num.to_F
|
14
|
+
|
15
|
+
class Numeric
|
16
|
+
@units
|
17
|
+
|
18
|
+
# The scale factor between C and F
|
19
|
+
CScale = 1.8
|
20
|
+
# The offset between C and F
|
21
|
+
FOffset = 32
|
22
|
+
# The offset between K and C
|
23
|
+
KOffset = 273.15
|
24
|
+
|
25
|
+
# The degree units the temperature is in. This defaults to "F" if
|
26
|
+
# not specified. Valid values are "C", "F", or "K" (R is not
|
27
|
+
# currently support... no one really uses that anyway).
|
28
|
+
def units
|
29
|
+
if @units
|
30
|
+
return @units
|
31
|
+
else
|
32
|
+
# this should auto detect the env, but for now, I live in the US
|
33
|
+
return "F"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def units=(u)
|
38
|
+
if u =~ /^(C|F|K)/
|
39
|
+
@units = u
|
40
|
+
end
|
41
|
+
return @units
|
42
|
+
end
|
43
|
+
|
44
|
+
# Is this a Farenheit temperature, returns a boolean
|
45
|
+
def is_F?
|
46
|
+
return self.units == "F"
|
47
|
+
end
|
48
|
+
|
49
|
+
# Is this a Celcius temperature, returns a boolean
|
50
|
+
def is_C?
|
51
|
+
return self.units == "C"
|
52
|
+
end
|
53
|
+
|
54
|
+
# Is this a Kelvin temperature, returns a boolean
|
55
|
+
def is_K?
|
56
|
+
return self.units == "K"
|
57
|
+
end
|
58
|
+
|
59
|
+
# Convert the temperature to Farenheit. If it's already in F, it
|
60
|
+
# returns itself.
|
61
|
+
def to_F
|
62
|
+
case self.units
|
63
|
+
when "F":
|
64
|
+
return self
|
65
|
+
when "C":
|
66
|
+
return self.c2f
|
67
|
+
when "K":
|
68
|
+
return self.k2f
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# Convert the temperature to Celcius. If it's already in C, it
|
73
|
+
# returns itself.
|
74
|
+
def to_C
|
75
|
+
case self.units
|
76
|
+
when "F":
|
77
|
+
return self.f2c
|
78
|
+
when "C":
|
79
|
+
return self
|
80
|
+
when "K":
|
81
|
+
return self.k2c
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# Convert the temperature to Kelvins. If it's already in K, it
|
86
|
+
# returns itself.
|
87
|
+
def to_K
|
88
|
+
case self.units
|
89
|
+
when "F":
|
90
|
+
return self.f2k
|
91
|
+
when "C":
|
92
|
+
return self.c2k
|
93
|
+
when "K":
|
94
|
+
return self
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def c2f
|
99
|
+
num = self * CScale + FOffset
|
100
|
+
num.units = "F"
|
101
|
+
return num
|
102
|
+
end
|
103
|
+
|
104
|
+
def f2c
|
105
|
+
num = (self - FOffset) / CScale
|
106
|
+
num.units = "C"
|
107
|
+
return num
|
108
|
+
end
|
109
|
+
|
110
|
+
def c2k
|
111
|
+
num = self + KOffset
|
112
|
+
num.units = "K"
|
113
|
+
return num
|
114
|
+
end
|
115
|
+
|
116
|
+
def k2c
|
117
|
+
num = self - KOffset
|
118
|
+
num.units = "C"
|
119
|
+
return num
|
120
|
+
end
|
121
|
+
|
122
|
+
def f2k
|
123
|
+
self.f2c.c2k
|
124
|
+
end
|
125
|
+
|
126
|
+
def k2f
|
127
|
+
self.k2c.c2f
|
128
|
+
end
|
129
|
+
|
130
|
+
# Compute the dewpoint for the temperature given a relative
|
131
|
+
# humidity. This is using the NOAA approximation for dewpoint
|
132
|
+
# calculation -
|
133
|
+
# http://en.wikipedia.org/wiki/Dew_point#Closer_approximation
|
134
|
+
def dewpoint(rh)
|
135
|
+
units = self.units
|
136
|
+
temp = self.to_C
|
137
|
+
e_sub_s = 6.112 * Math.exp((17.76 * temp) / (temp + 243.5))
|
138
|
+
e = rh * e_sub_s / 100
|
139
|
+
dew = 243.5 * Math.log(e / 6.112) / (17.67 - Math.log(e / 6.112))
|
140
|
+
dew.units = "C"
|
141
|
+
final = dew.send("to_#{units}")
|
142
|
+
return final
|
143
|
+
end
|
144
|
+
|
145
|
+
|
146
|
+
end
|
147
|
+
|
148
|
+
class String
|
149
|
+
|
150
|
+
# Parse a string that looks like a temperature into a temperature
|
151
|
+
# of the right units. It handles strings of the format
|
152
|
+
#
|
153
|
+
# 35.1C
|
154
|
+
# 72K
|
155
|
+
# -40F
|
156
|
+
#
|
157
|
+
# Decimals are support, as are negative numbers. The units must
|
158
|
+
# be C, K, or F, and not have a space between the numer and the
|
159
|
+
# units
|
160
|
+
def to_degrees
|
161
|
+
if self =~ /^(-?)(\d+)\.(\d+)(F|C|K)$/
|
162
|
+
tmp = "#{$1}#{$2}.#{$3}".to_f
|
163
|
+
tmp.units = $4
|
164
|
+
return tmp
|
165
|
+
elsif self =~ /^(-?)(\d+)(F|C|K)$/
|
166
|
+
tmp = "#{$1}#{$2}".to_f
|
167
|
+
tmp.units = $3
|
168
|
+
return tmp
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
|
173
|
+
end
|
174
|
+
|
@@ -0,0 +1,69 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
require "test/unit"
|
4
|
+
require "temperature"
|
5
|
+
|
6
|
+
class ConversionTest < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def test_from_string_F
|
9
|
+
numbers = [32.1, 23, -14.1, -7]
|
10
|
+
numbers.each do |num|
|
11
|
+
temp = "#{num}F".to_degrees
|
12
|
+
assert_kind_of(Numeric, temp)
|
13
|
+
assert_equal(temp, num)
|
14
|
+
assert_equal(temp.units, "F")
|
15
|
+
assert(temp.is_F?)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_from_string_C
|
20
|
+
numbers = [32.1, 23, -14.1, -7]
|
21
|
+
numbers.each do |num|
|
22
|
+
temp = "#{num}C".to_degrees
|
23
|
+
assert_kind_of(Numeric, temp)
|
24
|
+
assert_equal(temp, num)
|
25
|
+
assert_equal(temp.units, "C")
|
26
|
+
assert(temp.is_C?)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_from_string_K
|
31
|
+
numbers = [32.1, 23, -14.1, -7]
|
32
|
+
numbers.each do |num|
|
33
|
+
temp = "#{num}K".to_degrees
|
34
|
+
assert_kind_of(Numeric, temp)
|
35
|
+
assert_equal(temp, num)
|
36
|
+
assert_equal(temp.units, "K")
|
37
|
+
assert(temp.is_K?)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_convert
|
42
|
+
f = [32.0, 212.0, -40.0, 32, 212, -40]
|
43
|
+
c = [0.0, 100.0, -40.0, 0, 100, -40]
|
44
|
+
k = [273.15, 373.15, 233.15, 273.15, 373.15, 233.15]
|
45
|
+
|
46
|
+
f.each_with_index do |n, i|
|
47
|
+
temp = "#{n}F".to_degrees
|
48
|
+
assert_in_delta(temp.to_C, c[i], 0.00001)
|
49
|
+
assert_in_delta(temp.to_F, f[i], 0.00001)
|
50
|
+
assert_in_delta(temp.to_K, k[i], 0.00001)
|
51
|
+
end
|
52
|
+
|
53
|
+
c.each_with_index do |n, i|
|
54
|
+
temp = "#{n}C".to_degrees
|
55
|
+
assert_in_delta(temp.to_C, c[i], 0.00001)
|
56
|
+
assert_in_delta(temp.to_F, f[i], 0.00001)
|
57
|
+
assert_in_delta(temp.to_K, k[i], 0.00001)
|
58
|
+
end
|
59
|
+
|
60
|
+
k.each_with_index do |n, i|
|
61
|
+
temp = "#{n}K".to_degrees
|
62
|
+
assert_in_delta(temp.to_C, c[i], 0.00001)
|
63
|
+
assert_in_delta(temp.to_F, f[i], 0.00001)
|
64
|
+
assert_in_delta(temp.to_K, k[i], 0.00001)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
@@ -0,0 +1,100 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
+
<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
|
3
|
+
<head>
|
4
|
+
<title>
|
5
|
+
C0 code coverage information
|
6
|
+
</title>
|
7
|
+
<style type='text/css'>
|
8
|
+
body { background-color: rgb(240, 240, 245); }
|
9
|
+
</style>
|
10
|
+
<style type='text/css'>
|
11
|
+
span.cross-ref-title { font-size: 140%; } span.cross-ref a {
|
12
|
+
text-decoration: none; } span.cross-ref { background-color:#f3f7fa;
|
13
|
+
border: 1px dashed #333; margin: 1em; padding: 0.5em; overflow: hidden; }
|
14
|
+
a.crossref-toggle { text-decoration: none; } span.marked0 {
|
15
|
+
background-color: rgb(185, 210, 200); display: block; } span.marked1 {
|
16
|
+
background-color: rgb(190, 215, 205); display: block; } span.inferred0 {
|
17
|
+
background-color: rgb(175, 200, 200); display: block; } span.inferred1 {
|
18
|
+
background-color: rgb(180, 205, 205); display: block; } span.uncovered0 {
|
19
|
+
background-color: rgb(225, 110, 110); display: block; } span.uncovered1 {
|
20
|
+
background-color: rgb(235, 120, 120); display: block; } span.overview {
|
21
|
+
border-bottom: 8px solid black; } div.overview { border-bottom: 8px solid
|
22
|
+
black; } body { font-family: verdana, arial, helvetica; } div.footer {
|
23
|
+
font-size: 68%; margin-top: 1.5em; } h1, h2, h3, h4, h5, h6 {
|
24
|
+
margin-bottom: 0.5em; } h5 { margin-top: 0.5em; } .hidden { display: none;
|
25
|
+
} div.separator { height: 10px; } /* Commented out for better readability,
|
26
|
+
esp. on IE */ /* table tr td, table tr th { font-size: 68%; } td.value
|
27
|
+
table tr td { font-size: 11px; } */ table.percent_graph { height: 12px;
|
28
|
+
border: #808080 1px solid; empty-cells: show; } table.percent_graph
|
29
|
+
td.covered { height: 10px; background: #00f000; } table.percent_graph
|
30
|
+
td.uncovered { height: 10px; background: #e00000; } table.percent_graph
|
31
|
+
td.NA { height: 10px; background: #eaeaea; } table.report {
|
32
|
+
border-collapse: collapse; width: 100%; } table.report td.heading {
|
33
|
+
background: #dcecff; border: #d0d0d0 1px solid; font-weight: bold;
|
34
|
+
text-align: center; } table.report td.heading:hover { background: #c0ffc0;
|
35
|
+
} table.report td.text { border: #d0d0d0 1px solid; } table.report
|
36
|
+
td.value, table.report td.lines_total, table.report td.lines_code {
|
37
|
+
text-align: right; border: #d0d0d0 1px solid; } table.report tr.light {
|
38
|
+
background-color: rgb(240, 240, 245); } table.report tr.dark {
|
39
|
+
background-color: rgb(230, 230, 235); }
|
40
|
+
</style>
|
41
|
+
<script type='text/javascript'>
|
42
|
+
// <![CDATA[ function toggleCode( id ) { if ( document.getElementById )
|
43
|
+
elem = document.getElementById( id ); else if ( document.all ) elem =
|
44
|
+
eval( "document.all." + id ); else return false; elemStyle = elem.style;
|
45
|
+
if ( elemStyle.display != "block" ) { elemStyle.display = "block" } else {
|
46
|
+
elemStyle.display = "none" } return true; } // Make cross-references
|
47
|
+
hidden by default document.writeln( "<style
|
48
|
+
type=\"text/css\">span.cross-ref { display: none }</style>" ) // ]]>
|
49
|
+
</script>
|
50
|
+
</head>
|
51
|
+
<body>
|
52
|
+
<h3>
|
53
|
+
C0 code coverage information
|
54
|
+
</h3>
|
55
|
+
<p>
|
56
|
+
Generated on Tue Mar 02 23:32:43 -0500 2010 with
|
57
|
+
<a href='http://eigenclass.org/hiki/rcov'>
|
58
|
+
rcov 0.8.1.2
|
59
|
+
</a>
|
60
|
+
</p>
|
61
|
+
<hr />
|
62
|
+
<table class='report'> <thead> <tr> <td class='heading'> Name </td> <td
|
63
|
+
class='heading'> Total lines </td> <td class='heading'> Lines of code </td>
|
64
|
+
<td class='heading'> Total coverage </td> <td class='heading'> Code coverage
|
65
|
+
</td> </tr> </thead> <tbody> <tr class='light'> <td> TOTAL </td> <td
|
66
|
+
class='lines_total'> <tt> 103 </tt> </td> <td class='lines_code'> <tt> 84
|
67
|
+
</tt> </td> <td> <table cellspacing='0' align='right' cellpadding='0'> <tr>
|
68
|
+
<td> <tt class='coverage_total'> 100.0% </tt> </td> <td> <table
|
69
|
+
class='percent_graph' cellspacing='0' width='100' cellpadding='0'> <tr> <td
|
70
|
+
class='covered' width='100' /> <td class='uncovered' width='0' /> </tr>
|
71
|
+
</table> </td> </tr> </table> </td> <td> <table cellspacing='0'
|
72
|
+
align='right' cellpadding='0'> <tr> <td> <tt class='coverage_code'> 100.0%
|
73
|
+
</tt> </td> <td> <table class='percent_graph' cellspacing='0'
|
74
|
+
width='100' cellpadding='0'> <tr> <td class='covered' width='100' /> <td
|
75
|
+
class='uncovered' width='0' /> </tr> </table> </td> </tr> </table> </td>
|
76
|
+
</tr> <tr class='dark'> <td> <a href='lib-temperature_rb.html'>
|
77
|
+
lib/temperature.rb </a> </td> <td class='lines_total'> <tt> 103 </tt> </td>
|
78
|
+
<td class='lines_code'> <tt> 84 </tt> </td> <td> <table cellspacing='0'
|
79
|
+
align='right' cellpadding='0'> <tr> <td> <tt class='coverage_total'> 100.0%
|
80
|
+
</tt> </td> <td> <table class='percent_graph' cellspacing='0'
|
81
|
+
width='100' cellpadding='0'> <tr> <td class='covered' width='100' /> <td
|
82
|
+
class='uncovered' width='0' /> </tr> </table> </td> </tr> </table> </td>
|
83
|
+
<td> <table cellspacing='0' align='right' cellpadding='0'> <tr> <td> <tt
|
84
|
+
class='coverage_code'> 100.0% </tt> </td> <td> <table
|
85
|
+
class='percent_graph' cellspacing='0' width='100' cellpadding='0'> <tr> <td
|
86
|
+
class='covered' width='100' /> <td class='uncovered' width='0' /> </tr>
|
87
|
+
</table> </td> </tr> </table> </td> </tr> </tbody> </table>
|
88
|
+
<hr />
|
89
|
+
<p> Generated using the <a href='http://eigenclass.org/hiki.rb?rcov'> rcov
|
90
|
+
code coverage analysis tool for Ruby </a> version 0.8.1.2. </p>
|
91
|
+
<p>
|
92
|
+
<a href='http://validator.w3.org/check/referer'>
|
93
|
+
<img src='http://www.w3.org/Icons/valid-xhtml11' height='31' alt='Valid XHTML 1.1!' width='88' />
|
94
|
+
</a>
|
95
|
+
<a href='http://jigsaw.w3.org/css-validator/check/referer'>
|
96
|
+
<img src='http://jigsaw.w3.org/css-validator/images/vcss' alt='Valid CSS!' style='border:0;width:88px;height:31px' />
|
97
|
+
</a>
|
98
|
+
</p>
|
99
|
+
</body>
|
100
|
+
</html>
|
@@ -0,0 +1,300 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
+
<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
|
3
|
+
<head>
|
4
|
+
<title>
|
5
|
+
lib/temperature.rb - C0 code coverage information
|
6
|
+
</title>
|
7
|
+
<style type='text/css'>
|
8
|
+
body { background-color: rgb(240, 240, 245); }
|
9
|
+
</style>
|
10
|
+
<style type='text/css'>
|
11
|
+
span.cross-ref-title { font-size: 140%; } span.cross-ref a {
|
12
|
+
text-decoration: none; } span.cross-ref { background-color:#f3f7fa;
|
13
|
+
border: 1px dashed #333; margin: 1em; padding: 0.5em; overflow: hidden; }
|
14
|
+
a.crossref-toggle { text-decoration: none; } span.marked0 {
|
15
|
+
background-color: rgb(185, 210, 200); display: block; } span.marked1 {
|
16
|
+
background-color: rgb(190, 215, 205); display: block; } span.inferred0 {
|
17
|
+
background-color: rgb(175, 200, 200); display: block; } span.inferred1 {
|
18
|
+
background-color: rgb(180, 205, 205); display: block; } span.uncovered0 {
|
19
|
+
background-color: rgb(225, 110, 110); display: block; } span.uncovered1 {
|
20
|
+
background-color: rgb(235, 120, 120); display: block; } span.overview {
|
21
|
+
border-bottom: 8px solid black; } div.overview { border-bottom: 8px solid
|
22
|
+
black; } body { font-family: verdana, arial, helvetica; } div.footer {
|
23
|
+
font-size: 68%; margin-top: 1.5em; } h1, h2, h3, h4, h5, h6 {
|
24
|
+
margin-bottom: 0.5em; } h5 { margin-top: 0.5em; } .hidden { display: none;
|
25
|
+
} div.separator { height: 10px; } /* Commented out for better readability,
|
26
|
+
esp. on IE */ /* table tr td, table tr th { font-size: 68%; } td.value
|
27
|
+
table tr td { font-size: 11px; } */ table.percent_graph { height: 12px;
|
28
|
+
border: #808080 1px solid; empty-cells: show; } table.percent_graph
|
29
|
+
td.covered { height: 10px; background: #00f000; } table.percent_graph
|
30
|
+
td.uncovered { height: 10px; background: #e00000; } table.percent_graph
|
31
|
+
td.NA { height: 10px; background: #eaeaea; } table.report {
|
32
|
+
border-collapse: collapse; width: 100%; } table.report td.heading {
|
33
|
+
background: #dcecff; border: #d0d0d0 1px solid; font-weight: bold;
|
34
|
+
text-align: center; } table.report td.heading:hover { background: #c0ffc0;
|
35
|
+
} table.report td.text { border: #d0d0d0 1px solid; } table.report
|
36
|
+
td.value, table.report td.lines_total, table.report td.lines_code {
|
37
|
+
text-align: right; border: #d0d0d0 1px solid; } table.report tr.light {
|
38
|
+
background-color: rgb(240, 240, 245); } table.report tr.dark {
|
39
|
+
background-color: rgb(230, 230, 235); }
|
40
|
+
</style>
|
41
|
+
<script type='text/javascript'>
|
42
|
+
// <![CDATA[ function toggleCode( id ) { if ( document.getElementById )
|
43
|
+
elem = document.getElementById( id ); else if ( document.all ) elem =
|
44
|
+
eval( "document.all." + id ); else return false; elemStyle = elem.style;
|
45
|
+
if ( elemStyle.display != "block" ) { elemStyle.display = "block" } else {
|
46
|
+
elemStyle.display = "none" } return true; } // Make cross-references
|
47
|
+
hidden by default document.writeln( "<style
|
48
|
+
type=\"text/css\">span.cross-ref { display: none }</style>" ) // ]]>
|
49
|
+
</script>
|
50
|
+
<style type='text/css'>
|
51
|
+
span.run0 { background-color: rgb(178, 204, 255); display: block; }
|
52
|
+
span.run1 { background-color: rgb(178, 206, 255); display: block; }
|
53
|
+
span.run2 { background-color: rgb(178, 209, 255); display: block; }
|
54
|
+
span.run3 { background-color: rgb(178, 211, 255); display: block; }
|
55
|
+
span.run4 { background-color: rgb(178, 214, 255); display: block; }
|
56
|
+
span.run5 { background-color: rgb(178, 218, 255); display: block; }
|
57
|
+
span.run6 { background-color: rgb(178, 220, 255); display: block; }
|
58
|
+
span.run7 { background-color: rgb(178, 223, 255); display: block; }
|
59
|
+
span.run8 { background-color: rgb(178, 225, 255); display: block; }
|
60
|
+
span.run9 { background-color: rgb(178, 228, 255); display: block; }
|
61
|
+
span.run10 { background-color: rgb(178, 232, 255); display: block; }
|
62
|
+
span.run11 { background-color: rgb(178, 234, 255); display: block; }
|
63
|
+
span.run12 { background-color: rgb(178, 237, 255); display: block; }
|
64
|
+
span.run13 { background-color: rgb(178, 239, 255); display: block; }
|
65
|
+
span.run14 { background-color: rgb(178, 242, 255); display: block; }
|
66
|
+
span.run15 { background-color: rgb(178, 246, 255); display: block; }
|
67
|
+
span.run16 { background-color: rgb(178, 248, 255); display: block; }
|
68
|
+
span.run17 { background-color: rgb(178, 251, 255); display: block; }
|
69
|
+
span.run18 { background-color: rgb(178, 253, 255); display: block; }
|
70
|
+
span.run19 { background-color: rgb(178, 255, 253); display: block; }
|
71
|
+
span.run20 { background-color: rgb(178, 255, 249); display: block; }
|
72
|
+
span.run21 { background-color: rgb(178, 255, 247); display: block; }
|
73
|
+
span.run22 { background-color: rgb(178, 255, 244); display: block; }
|
74
|
+
span.run23 { background-color: rgb(178, 255, 242); display: block; }
|
75
|
+
span.run24 { background-color: rgb(178, 255, 239); display: block; }
|
76
|
+
span.run25 { background-color: rgb(178, 255, 235); display: block; }
|
77
|
+
span.run26 { background-color: rgb(178, 255, 233); display: block; }
|
78
|
+
span.run27 { background-color: rgb(178, 255, 230); display: block; }
|
79
|
+
span.run28 { background-color: rgb(178, 255, 228); display: block; }
|
80
|
+
span.run29 { background-color: rgb(178, 255, 225); display: block; }
|
81
|
+
span.run30 { background-color: rgb(178, 255, 221); display: block; }
|
82
|
+
span.run31 { background-color: rgb(178, 255, 219); display: block; }
|
83
|
+
span.run32 { background-color: rgb(178, 255, 216); display: block; }
|
84
|
+
span.run33 { background-color: rgb(178, 255, 214); display: block; }
|
85
|
+
span.run34 { background-color: rgb(178, 255, 211); display: block; }
|
86
|
+
span.run35 { background-color: rgb(178, 255, 207); display: block; }
|
87
|
+
span.run36 { background-color: rgb(178, 255, 205); display: block; }
|
88
|
+
span.run37 { background-color: rgb(178, 255, 202); display: block; }
|
89
|
+
span.run38 { background-color: rgb(178, 255, 200); display: block; }
|
90
|
+
span.run39 { background-color: rgb(178, 255, 197); display: block; }
|
91
|
+
span.run40 { background-color: rgb(178, 255, 193); display: block; }
|
92
|
+
span.run41 { background-color: rgb(178, 255, 191); display: block; }
|
93
|
+
span.run42 { background-color: rgb(178, 255, 188); display: block; }
|
94
|
+
span.run43 { background-color: rgb(178, 255, 186); display: block; }
|
95
|
+
span.run44 { background-color: rgb(178, 255, 183); display: block; }
|
96
|
+
span.run45 { background-color: rgb(178, 255, 179); display: block; }
|
97
|
+
span.run46 { background-color: rgb(179, 255, 178); display: block; }
|
98
|
+
span.run47 { background-color: rgb(182, 255, 178); display: block; }
|
99
|
+
span.run48 { background-color: rgb(184, 255, 178); display: block; }
|
100
|
+
span.run49 { background-color: rgb(187, 255, 178); display: block; }
|
101
|
+
span.run50 { background-color: rgb(191, 255, 178); display: block; }
|
102
|
+
span.run51 { background-color: rgb(193, 255, 178); display: block; }
|
103
|
+
span.run52 { background-color: rgb(196, 255, 178); display: block; }
|
104
|
+
span.run53 { background-color: rgb(198, 255, 178); display: block; }
|
105
|
+
span.run54 { background-color: rgb(201, 255, 178); display: block; }
|
106
|
+
span.run55 { background-color: rgb(205, 255, 178); display: block; }
|
107
|
+
span.run56 { background-color: rgb(207, 255, 178); display: block; }
|
108
|
+
span.run57 { background-color: rgb(210, 255, 178); display: block; }
|
109
|
+
span.run58 { background-color: rgb(212, 255, 178); display: block; }
|
110
|
+
span.run59 { background-color: rgb(215, 255, 178); display: block; }
|
111
|
+
span.run60 { background-color: rgb(219, 255, 178); display: block; }
|
112
|
+
span.run61 { background-color: rgb(221, 255, 178); display: block; }
|
113
|
+
span.run62 { background-color: rgb(224, 255, 178); display: block; }
|
114
|
+
span.run63 { background-color: rgb(226, 255, 178); display: block; }
|
115
|
+
span.run64 { background-color: rgb(229, 255, 178); display: block; }
|
116
|
+
span.run65 { background-color: rgb(233, 255, 178); display: block; }
|
117
|
+
span.run66 { background-color: rgb(235, 255, 178); display: block; }
|
118
|
+
span.run67 { background-color: rgb(238, 255, 178); display: block; }
|
119
|
+
span.run68 { background-color: rgb(240, 255, 178); display: block; }
|
120
|
+
span.run69 { background-color: rgb(243, 255, 178); display: block; }
|
121
|
+
span.run70 { background-color: rgb(247, 255, 178); display: block; }
|
122
|
+
span.run71 { background-color: rgb(249, 255, 178); display: block; }
|
123
|
+
span.run72 { background-color: rgb(252, 255, 178); display: block; }
|
124
|
+
span.run73 { background-color: rgb(255, 255, 178); display: block; }
|
125
|
+
span.run74 { background-color: rgb(255, 252, 178); display: block; }
|
126
|
+
span.run75 { background-color: rgb(255, 248, 178); display: block; }
|
127
|
+
span.run76 { background-color: rgb(255, 246, 178); display: block; }
|
128
|
+
span.run77 { background-color: rgb(255, 243, 178); display: block; }
|
129
|
+
span.run78 { background-color: rgb(255, 240, 178); display: block; }
|
130
|
+
span.run79 { background-color: rgb(255, 238, 178); display: block; }
|
131
|
+
span.run80 { background-color: rgb(255, 234, 178); display: block; }
|
132
|
+
span.run81 { background-color: rgb(255, 232, 178); display: block; }
|
133
|
+
span.run82 { background-color: rgb(255, 229, 178); display: block; }
|
134
|
+
span.run83 { background-color: rgb(255, 226, 178); display: block; }
|
135
|
+
span.run84 { background-color: rgb(255, 224, 178); display: block; }
|
136
|
+
span.run85 { background-color: rgb(255, 220, 178); display: block; }
|
137
|
+
span.run86 { background-color: rgb(255, 218, 178); display: block; }
|
138
|
+
span.run87 { background-color: rgb(255, 215, 178); display: block; }
|
139
|
+
span.run88 { background-color: rgb(255, 212, 178); display: block; }
|
140
|
+
span.run89 { background-color: rgb(255, 210, 178); display: block; }
|
141
|
+
span.run90 { background-color: rgb(255, 206, 178); display: block; }
|
142
|
+
span.run91 { background-color: rgb(255, 204, 178); display: block; }
|
143
|
+
span.run92 { background-color: rgb(255, 201, 178); display: block; }
|
144
|
+
span.run93 { background-color: rgb(255, 198, 178); display: block; }
|
145
|
+
span.run94 { background-color: rgb(255, 196, 178); display: block; }
|
146
|
+
span.run95 { background-color: rgb(255, 192, 178); display: block; }
|
147
|
+
span.run96 { background-color: rgb(255, 189, 178); display: block; }
|
148
|
+
span.run97 { background-color: rgb(255, 187, 178); display: block; }
|
149
|
+
span.run98 { background-color: rgb(255, 184, 178); display: block; }
|
150
|
+
span.run99 { background-color: rgb(255, 182, 178); display: block; }
|
151
|
+
span.run100 { background-color: rgb(255, 178, 178); display: block; }
|
152
|
+
</style>
|
153
|
+
</head>
|
154
|
+
<body>
|
155
|
+
<h3>
|
156
|
+
C0 code coverage information
|
157
|
+
</h3>
|
158
|
+
<p>
|
159
|
+
Generated on Tue Mar 02 23:32:43 -0500 2010 with
|
160
|
+
<a href='http://eigenclass.org/hiki/rcov'>
|
161
|
+
rcov 0.8.1.2
|
162
|
+
</a>
|
163
|
+
</p>
|
164
|
+
<hr />
|
165
|
+
<pre><span class='marked0'>Code reported as executed by Ruby looks like
|
166
|
+
this... </span><span class='marked1'>and this: this line is also marked as
|
167
|
+
covered. </span><span class='inferred0'>Lines considered as run by rcov, but
|
168
|
+
not reported by Ruby, look like this, </span><span class='inferred1'>and
|
169
|
+
this: these lines were inferred by rcov (using simple heuristics).
|
170
|
+
</span><span class='uncovered0'>Finally, here's a line marked as not
|
171
|
+
executed. </span></pre>
|
172
|
+
<table class='report'> <thead> <tr> <td class='heading'> Name </td> <td
|
173
|
+
class='heading'> Total lines </td> <td class='heading'> Lines of code </td>
|
174
|
+
<td class='heading'> Total coverage </td> <td class='heading'> Code coverage
|
175
|
+
</td> </tr> </thead> <tbody> <tr class='light'> <td> <a
|
176
|
+
href='lib-temperature_rb.html'> lib/temperature.rb </a> </td> <td
|
177
|
+
class='lines_total'> <tt> 103 </tt> </td> <td class='lines_code'> <tt> 84
|
178
|
+
</tt> </td> <td> <table cellspacing='0' align='right' cellpadding='0'> <tr>
|
179
|
+
<td> <tt class='coverage_total'> 100.0% </tt> </td> <td> <table
|
180
|
+
class='percent_graph' cellspacing='0' width='100' cellpadding='0'> <tr> <td
|
181
|
+
class='covered' width='100' /> <td class='uncovered' width='0' /> </tr>
|
182
|
+
</table> </td> </tr> </table> </td> <td> <table cellspacing='0'
|
183
|
+
align='right' cellpadding='0'> <tr> <td> <tt class='coverage_code'> 100.0%
|
184
|
+
</tt> </td> <td> <table class='percent_graph' cellspacing='0'
|
185
|
+
width='100' cellpadding='0'> <tr> <td class='covered' width='100' /> <td
|
186
|
+
class='uncovered' width='0' /> </tr> </table> </td> </tr> </table> </td>
|
187
|
+
</tr> </tbody> </table><pre><span class="marked1"><a name="line1"></a> 1
|
188
|
+
class Numeric </span><span class="marked0"><a name="line2"></a> 2
|
189
|
+
attr_accessor :units </span><span class="inferred1"><a name="line3"></a> 3
|
190
|
+
</span><span class="marked0"><a name="line4"></a> 4 CScale = 1.8
|
191
|
+
</span><span class="marked1"><a name="line5"></a> 5 FOffset = 32
|
192
|
+
</span><span class="marked0"><a name="line6"></a> 6 KOffset = 273.15
|
193
|
+
</span><span class="inferred1"><a name="line7"></a> 7 </span><span
|
194
|
+
class="marked0"><a name="line8"></a> 8 def is_F? </span><span
|
195
|
+
class="marked1"><a name="line9"></a> 9 return self.units == "F"
|
196
|
+
</span><span class="inferred0"><a name="line10"></a> 10 end </span><span
|
197
|
+
class="inferred1"><a name="line11"></a> 11 </span><span class="marked0"><a
|
198
|
+
name="line12"></a> 12 def is_C? </span><span class="marked1"><a
|
199
|
+
name="line13"></a> 13 return self.units == "C" </span><span
|
200
|
+
class="inferred0"><a name="line14"></a> 14 end </span><span
|
201
|
+
class="inferred1"><a name="line15"></a> 15 </span><span class="marked0"><a
|
202
|
+
name="line16"></a> 16 def is_K? </span><span class="marked1"><a
|
203
|
+
name="line17"></a> 17 return self.units == "K" </span><span
|
204
|
+
class="inferred0"><a name="line18"></a> 18 end </span><span
|
205
|
+
class="inferred1"><a name="line19"></a> 19 </span><span class="marked0"><a
|
206
|
+
name="line20"></a> 20 def to_F </span><span class="marked1"><a
|
207
|
+
name="line21"></a> 21 case self.units </span><span class="marked0"><a
|
208
|
+
name="line22"></a> 22 when "F": </span><span class="marked1"><a
|
209
|
+
name="line23"></a> 23 return self </span><span class="marked0"><a
|
210
|
+
name="line24"></a> 24 when "C": </span><span class="marked1"><a
|
211
|
+
name="line25"></a> 25 return self.c2f </span><span class="marked0"><a
|
212
|
+
name="line26"></a> 26 when "K": </span><span class="marked1"><a
|
213
|
+
name="line27"></a> 27 return self.k2f </span><span class="inferred0"><a
|
214
|
+
name="line28"></a> 28 end </span><span class="inferred1"><a
|
215
|
+
name="line29"></a> 29 end </span><span class="inferred0"><a
|
216
|
+
name="line30"></a> 30 </span><span class="marked1"><a name="line31"></a> 31
|
217
|
+
def to_C </span><span class="marked0"><a name="line32"></a> 32 case
|
218
|
+
self.units </span><span class="marked1"><a name="line33"></a> 33 when
|
219
|
+
"F": </span><span class="marked0"><a name="line34"></a> 34 return
|
220
|
+
self.f2c </span><span class="marked1"><a name="line35"></a> 35 when
|
221
|
+
"C": </span><span class="marked0"><a name="line36"></a> 36 return
|
222
|
+
self </span><span class="marked1"><a name="line37"></a> 37 when
|
223
|
+
"K": </span><span class="marked0"><a name="line38"></a> 38 return
|
224
|
+
self.k2c </span><span class="inferred1"><a name="line39"></a> 39 end
|
225
|
+
</span><span class="inferred0"><a name="line40"></a> 40 end </span><span
|
226
|
+
class="inferred1"><a name="line41"></a> 41 </span><span class="marked0"><a
|
227
|
+
name="line42"></a> 42 def to_K </span><span class="marked1"><a
|
228
|
+
name="line43"></a> 43 case self.units </span><span class="marked0"><a
|
229
|
+
name="line44"></a> 44 when "F": </span><span class="marked1"><a
|
230
|
+
name="line45"></a> 45 return self.f2k </span><span class="marked0"><a
|
231
|
+
name="line46"></a> 46 when "C": </span><span class="marked1"><a
|
232
|
+
name="line47"></a> 47 return self.c2k </span><span class="marked0"><a
|
233
|
+
name="line48"></a> 48 when "K": </span><span class="marked1"><a
|
234
|
+
name="line49"></a> 49 return self </span><span class="inferred0"><a
|
235
|
+
name="line50"></a> 50 end </span><span class="inferred1"><a
|
236
|
+
name="line51"></a> 51 end </span><span class="inferred0"><a
|
237
|
+
name="line52"></a> 52 </span><span class="marked1"><a name="line53"></a> 53
|
238
|
+
def c2f </span><span class="marked0"><a name="line54"></a> 54 num = self *
|
239
|
+
CScale + FOffset </span><span class="marked1"><a name="line55"></a> 55
|
240
|
+
num.units = "F" </span><span class="marked0"><a name="line56"></a>
|
241
|
+
56 return num </span><span class="inferred1"><a name="line57"></a> 57 end
|
242
|
+
</span><span class="inferred0"><a name="line58"></a> 58 </span><span
|
243
|
+
class="marked1"><a name="line59"></a> 59 def f2c </span><span
|
244
|
+
class="marked0"><a name="line60"></a> 60 num = (self - FOffset) / CScale
|
245
|
+
</span><span class="marked1"><a name="line61"></a> 61 num.units =
|
246
|
+
"C" </span><span class="marked0"><a name="line62"></a> 62 return
|
247
|
+
num </span><span class="inferred1"><a name="line63"></a> 63 end </span><span
|
248
|
+
class="inferred0"><a name="line64"></a> 64 </span><span class="marked1"><a
|
249
|
+
name="line65"></a> 65 def c2k </span><span class="marked0"><a
|
250
|
+
name="line66"></a> 66 num = self + KOffset </span><span class="marked1"><a
|
251
|
+
name="line67"></a> 67 num.units = "K" </span><span
|
252
|
+
class="marked0"><a name="line68"></a> 68 return num </span><span
|
253
|
+
class="inferred1"><a name="line69"></a> 69 end </span><span
|
254
|
+
class="inferred0"><a name="line70"></a> 70 </span><span class="marked1"><a
|
255
|
+
name="line71"></a> 71 def k2c </span><span class="marked0"><a
|
256
|
+
name="line72"></a> 72 num = self - KOffset </span><span class="marked1"><a
|
257
|
+
name="line73"></a> 73 num.units = "C" </span><span
|
258
|
+
class="marked0"><a name="line74"></a> 74 return num </span><span
|
259
|
+
class="inferred1"><a name="line75"></a> 75 end </span><span
|
260
|
+
class="inferred0"><a name="line76"></a> 76 </span><span class="marked1"><a
|
261
|
+
name="line77"></a> 77 def f2k </span><span class="marked0"><a
|
262
|
+
name="line78"></a> 78 self.f2c.c2k </span><span class="inferred1"><a
|
263
|
+
name="line79"></a> 79 end </span><span class="inferred0"><a
|
264
|
+
name="line80"></a> 80 </span><span class="marked1"><a name="line81"></a> 81
|
265
|
+
def k2f </span><span class="marked0"><a name="line82"></a> 82 self.k2c.c2f
|
266
|
+
</span><span class="inferred1"><a name="line83"></a> 83 end </span><span
|
267
|
+
class="inferred0"><a name="line84"></a> 84 </span><span class="inferred1"><a
|
268
|
+
name="line85"></a> 85 </span><span class="inferred0"><a name="line86"></a>
|
269
|
+
86 end </span><span class="inferred1"><a name="line87"></a> 87 </span><span
|
270
|
+
class="marked0"><a name="line88"></a> 88 class String </span><span
|
271
|
+
class="marked1"><a name="line89"></a> 89 def to_degrees </span><span
|
272
|
+
class="marked0"><a name="line90"></a> 90 if self =~
|
273
|
+
/^(-?)(\d+)\.(\d+)(F|C|K)$/ </span><span class="marked1"><a
|
274
|
+
name="line91"></a> 91 tmp = "#{$1}#{$2}.#{$3}".to_f </span><span
|
275
|
+
class="marked0"><a name="line92"></a> 92 tmp.units = $4 </span><span
|
276
|
+
class="marked1"><a name="line93"></a> 93 return tmp </span><span
|
277
|
+
class="marked0"><a name="line94"></a> 94 elsif self =~ /^(-?)(\d+)(F|C|K)$/
|
278
|
+
</span><span class="marked1"><a name="line95"></a> 95 tmp =
|
279
|
+
"#{$1}#{$2}".to_f </span><span class="marked0"><a
|
280
|
+
name="line96"></a> 96 tmp.units = $3 </span><span class="marked1"><a
|
281
|
+
name="line97"></a> 97 return tmp </span><span class="inferred0"><a
|
282
|
+
name="line98"></a> 98 end </span><span class="inferred1"><a
|
283
|
+
name="line99"></a> 99 end </span><span class="inferred0"><a
|
284
|
+
name="line100"></a>100 </span><span class="inferred1"><a
|
285
|
+
name="line101"></a>101 </span><span class="inferred0"><a
|
286
|
+
name="line102"></a>102 end </span><span class="inferred1"><a
|
287
|
+
name="line103"></a>103 </span></pre>
|
288
|
+
<hr />
|
289
|
+
<p> Generated using the <a href='http://eigenclass.org/hiki.rb?rcov'> rcov
|
290
|
+
code coverage analysis tool for Ruby </a> version 0.8.1.2. </p>
|
291
|
+
<p>
|
292
|
+
<a href='http://validator.w3.org/check/referer'>
|
293
|
+
<img src='http://www.w3.org/Icons/valid-xhtml10' height='31' alt='Valid XHTML 1.0!' width='88' />
|
294
|
+
</a>
|
295
|
+
<a href='http://jigsaw.w3.org/css-validator/check/referer'>
|
296
|
+
<img src='http://jigsaw.w3.org/css-validator/images/vcss' alt='Valid CSS!' style='border:0;width:88px;height:31px' />
|
297
|
+
</a>
|
298
|
+
</p>
|
299
|
+
</body>
|
300
|
+
</html>
|