Class: Bioroebe::ColourScheme::Score
- Inherits:
-
Object
- Object
- Bioroebe::ColourScheme::Score
show all
- Defined in:
- lib/bioroebe/colours/colour_schemes/score.rb
Overview
Bioroebe::ColourScheme::Score
Class Method Summary
collapse
-
.[](i) ⇒ Object
# === Bioroebe::ColourScheme::Score[] ========================================================================= #.
-
.colours ⇒ Object
# === Bioroebe::ColourScheme::Score.colours ========================================================================= #.
-
.max(i = nil) ⇒ Object
# === Score.max ========================================================================= #.
-
.min(i = nil) ⇒ Object
# === Bioroebe::ColourScheme::Score.min ========================================================================= #.
-
.percent_to_hex(percent) ⇒ Object
# === Bioroebe::ColourScheme::Score.percent_to_hex ========================================================================= #.
-
.rgb_percent_to_hex(red, green, blue) ⇒ Object
# === Bioroebe::ColourScheme::Score.rgb_percent_to_hex ========================================================================= #.
-
.score_to_percent(score, min, max) ⇒ Object
# === Bioroebe::ColourScheme::Score.score_to_percent ========================================================================= #.
-
.score_to_rgb_hex(score, min, max) ⇒ Object
# === Bioroebe::ColourScheme::Score.score_to_rgb_hex ========================================================================= #.
-
.scores ⇒ Object
# === Score.scores ========================================================================= #.
Class Method Details
.[](i) ⇒ Object
#
Bioroebe::ColourScheme::Score[]
#
118
119
120
121
|
# File 'lib/bioroebe/colours/colour_schemes/score.rb', line 118
def self.[](i)
return if i.nil?
@colours[i.to_s.upcase]
end
|
.colours ⇒ Object
#
Bioroebe::ColourScheme::Score.colours
#
111
112
113
|
# File 'lib/bioroebe/colours/colour_schemes/score.rb', line 111
def self.colours
@colours
end
|
.max(i = nil) ⇒ Object
97
98
99
|
# File 'lib/bioroebe/colours/colour_schemes/score.rb', line 97
def self.max(i = nil)
@max
end
|
.min(i = nil) ⇒ Object
#
Bioroebe::ColourScheme::Score.min
#
90
91
92
|
# File 'lib/bioroebe/colours/colour_schemes/score.rb', line 90
def self.min(i = nil)
@min
end
|
.percent_to_hex(percent) ⇒ Object
#
Bioroebe::ColourScheme::Score.percent_to_hex
#
36
37
38
39
40
41
42
|
# File 'lib/bioroebe/colours/colour_schemes/score.rb', line 36
def self.percent_to_hex(percent)
percent = percent.to_f if percent.is_a? String
if (percent > 1.0) or (percent < 0.0) or percent.nil?
raise 'Percentage must be between 0.0 and 1.0'
end
'%02X' % (percent * 255.0)
end
|
.rgb_percent_to_hex(red, green, blue) ⇒ Object
#
Bioroebe::ColourScheme::Score.rgb_percent_to_hex
#
.score_to_percent(score, min, max) ⇒ Object
#
Bioroebe::ColourScheme::Score.score_to_percent
#
72
73
74
75
76
77
78
|
# File 'lib/bioroebe/colours/colour_schemes/score.rb', line 72
def self.score_to_percent(score, min, max)
percent = (score.to_f - min) / (max.to_f - min)
percent = 1.0 if percent > 1.0
percent = 0.0 if percent < 0.0
percent
end
|
.score_to_rgb_hex(score, min, max) ⇒ Object
#
Bioroebe::ColourScheme::Score.score_to_rgb_hex
#
60
61
62
63
64
65
66
67
|
# File 'lib/bioroebe/colours/colour_schemes/score.rb', line 60
def self.score_to_rgb_hex(
score,
min,
max
)
percent = score_to_percent(score, min, max)
Score.rgb_percent_to_hex(percent, 0.0, 1.0-percent)
end
|
.scores ⇒ Object
104
105
106
|
# File 'lib/bioroebe/colours/colour_schemes/score.rb', line 104
def self.scores
@scores
end
|