Class: TNS::Color::Hex
Overview
Hex color representation
Instance Attribute Summary collapse
-
#blue ⇒ Object
readonly
Returns the value of attribute blue.
-
#green ⇒ Object
readonly
Returns the value of attribute green.
-
#red ⇒ Object
readonly
Returns the value of attribute red.
Instance Method Summary collapse
-
#initialize(rgb) ⇒ Hex
constructor
A new instance of Hex.
- #to_css ⇒ Object
- #to_s ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(rgb) ⇒ Hex
Returns a new instance of Hex.
9 10 11 12 13 |
# File 'lib/tns/color/hex.rb', line 9 def initialize(rgb) @red, @green, @blue = [rgb.red, rgb.green, rgb.blue].map { |color| normalize(color) } super() end |
Instance Attribute Details
#blue ⇒ Object (readonly)
Returns the value of attribute blue.
7 8 9 |
# File 'lib/tns/color/hex.rb', line 7 def blue @blue end |
#green ⇒ Object (readonly)
Returns the value of attribute green.
7 8 9 |
# File 'lib/tns/color/hex.rb', line 7 def green @green end |
#red ⇒ Object (readonly)
Returns the value of attribute red.
7 8 9 |
# File 'lib/tns/color/hex.rb', line 7 def red @red end |
Instance Method Details
#to_css ⇒ Object
15 16 17 |
# File 'lib/tns/color/hex.rb', line 15 def to_css "##{self}" end |
#to_s ⇒ Object
19 20 21 |
# File 'lib/tns/color/hex.rb', line 19 def to_s "#{red}#{green}#{blue}" end |