Class: Dedalus::ColorPalette
- Inherits:
-
Object
- Object
- Dedalus::ColorPalette
- Defined in:
- lib/dedalus/palette.rb
Instance Attribute Summary collapse
-
#black ⇒ Object
Returns the value of attribute black.
-
#blue ⇒ Object
Returns the value of attribute blue.
-
#gray ⇒ Object
Returns the value of attribute gray.
-
#green ⇒ Object
Returns the value of attribute green.
-
#purple ⇒ Object
Returns the value of attribute purple.
-
#red ⇒ Object
Returns the value of attribute red.
-
#white ⇒ Object
Returns the value of attribute white.
-
#yellow ⇒ Object
Returns the value of attribute yellow.
Instance Method Summary collapse
- #decode_color(color) ⇒ Object
-
#initialize(red:, green:, blue:, yellow:, purple:, gray:, white: Color.new(240,240,240), black: Color.new(20,20,20)) ⇒ ColorPalette
constructor
A new instance of ColorPalette.
Constructor Details
#initialize(red:, green:, blue:, yellow:, purple:, gray:, white: Color.new(240,240,240), black: Color.new(20,20,20)) ⇒ ColorPalette
Returns a new instance of ColorPalette.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/dedalus/palette.rb', line 35 def initialize( red:, green:, blue:, yellow:, purple:, gray:, white: Color.new(240,240,240), black: Color.new(20,20,20) ) @red = red @green = green @blue = blue @yellow = yellow @purple = purple @gray = gray @white = white @black = black end |
Instance Attribute Details
#black ⇒ Object
Returns the value of attribute black.
34 35 36 |
# File 'lib/dedalus/palette.rb', line 34 def black @black end |
#blue ⇒ Object
Returns the value of attribute blue.
34 35 36 |
# File 'lib/dedalus/palette.rb', line 34 def blue @blue end |
#gray ⇒ Object
Returns the value of attribute gray.
34 35 36 |
# File 'lib/dedalus/palette.rb', line 34 def gray @gray end |
#green ⇒ Object
Returns the value of attribute green.
34 35 36 |
# File 'lib/dedalus/palette.rb', line 34 def green @green end |
#purple ⇒ Object
Returns the value of attribute purple.
34 35 36 |
# File 'lib/dedalus/palette.rb', line 34 def purple @purple end |
#red ⇒ Object
Returns the value of attribute red.
34 35 36 |
# File 'lib/dedalus/palette.rb', line 34 def red @red end |
#white ⇒ Object
Returns the value of attribute white.
34 35 36 |
# File 'lib/dedalus/palette.rb', line 34 def white @white end |
#yellow ⇒ Object
Returns the value of attribute yellow.
34 35 36 |
# File 'lib/dedalus/palette.rb', line 34 def yellow @yellow end |
Instance Method Details
#decode_color(color) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/dedalus/palette.rb', line 50 def decode_color(color) return color if color.is_a?(Dedalus::Color) case color when 'red' then red when 'lightred' then red.lighten when 'darkred' then red.darken when 'green' then green when 'lightgreen' then green.lighten when 'darkgreen' then green.darken when 'blue' then blue when 'lightblue' then blue.lighten when 'darkblue' then blue.darken when 'yellow' then yellow when 'lightyellow' then yellow.lighten when 'darkyellow' then yellow.darken when 'gray' then gray when 'lightgray' then gray.lighten when 'darkgray' then gray.darken when 'purple' then purple when 'lightpurple' then purple.lighten when 'darkpurple' then purple.darken when 'white' then white when 'black' then black else raise "Unknown color string given to #{self.class.name}#decode_color: #{color}" end end |