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[]
#
107
108
109
110
|
# File 'lib/bioroebe/colours/colour_schemes/score.rb', line 107
def self.[](i)
return if i.nil?
@colours[i.to_s.upcase]
end
|
.colours ⇒ Object
#
Bioroebe::ColourScheme::Score.colours
#
100
101
102
|
# File 'lib/bioroebe/colours/colour_schemes/score.rb', line 100
def self.colours
@colours
end
|
.max(i = nil) ⇒ Object
86
87
88
|
# File 'lib/bioroebe/colours/colour_schemes/score.rb', line 86
def self.max(i = nil)
@max
end
|
.min(i = nil) ⇒ Object
#
Bioroebe::ColourScheme::Score.min
#
79
80
81
|
# File 'lib/bioroebe/colours/colour_schemes/score.rb', line 79
def self.min(i = nil)
@min
end
|
.percent_to_hex(percent) ⇒ Object
#
Bioroebe::ColourScheme::Score.percent_to_hex
#
33
34
35
36
37
38
39
|
# File 'lib/bioroebe/colours/colour_schemes/score.rb', line 33
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
#
61
62
63
64
65
66
67
|
# File 'lib/bioroebe/colours/colour_schemes/score.rb', line 61
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
#
53
54
55
56
|
# File 'lib/bioroebe/colours/colour_schemes/score.rb', line 53
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
93
94
95
|
# File 'lib/bioroebe/colours/colour_schemes/score.rb', line 93
def self.scores
@scores
end
|