Class: Workarea::Storefront::ColorTools
- Inherits:
-
Object
- Object
- Workarea::Storefront::ColorTools
- Defined in:
- app/services/workarea/storefront/color_tools.rb
Instance Method Summary collapse
- #alpha ⇒ Object
- #hex_to_rgb ⇒ Object
-
#initialize(color) ⇒ ColorTools
constructor
A new instance of ColorTools.
- #rgba ⇒ Object
Constructor Details
#initialize(color) ⇒ ColorTools
Returns a new instance of ColorTools.
4 5 6 |
# File 'app/services/workarea/storefront/color_tools.rb', line 4 def initialize(color) @color = color end |
Instance Method Details
#alpha ⇒ Object
14 15 16 |
# File 'app/services/workarea/storefront/color_tools.rb', line 14 def alpha @color[:alpha].to_f / 100.0 end |
#hex_to_rgb ⇒ Object
18 19 20 21 |
# File 'app/services/workarea/storefront/color_tools.rb', line 18 def hex_to_rgb r, g, b = @color[:hex].match(/#(..)(..)(..)/).captures "#{r.hex}, #{g.hex}, #{b.hex}" end |
#rgba ⇒ Object
8 9 10 11 12 |
# File 'app/services/workarea/storefront/color_tools.rb', line 8 def rgba if @color[:hex] =~ /#(..)(..)(..)/ "#{hex_to_rgb}, #{alpha}" end end |