Sha256: 7e5660a0d05d295dc1c9162c20e344ae5c5544c5543eda5aac09fd0628aff493

Contents?: true

Size: 450 Bytes

Versions: 3

Compression:

Stored size: 450 Bytes

Contents

module Workarea
  module Storefront
    class ColorTools
      def initialize(color)
        @color = color
      end

      def rgba
        if @color[:hex] =~ /#(..)(..)(..)/
          "#{hex_to_rgb}, #{alpha}"
        end
      end

      def alpha
        @color[:alpha].to_f / 100.0
      end

      def hex_to_rgb
        r, g, b = @color[:hex].match(/#(..)(..)(..)/).captures
        "#{r.hex}, #{g.hex}, #{b.hex}"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
workarea-super_hero-2.3.0 app/services/workarea/storefront/color_tools.rb
workarea-super_hero-2.2.2 app/services/workarea/storefront/color_tools.rb
workarea-super_hero-2.2.1 app/services/workarea/storefront/color_tools.rb