Sha256: 517afa055878c939ad26c604c1b745d04c483fc3fa0f0a8d054db586d2094257

Contents?: true

Size: 384 Bytes

Versions: 1

Compression:

Stored size: 384 Bytes

Contents

module Iz
  class HexColor
    REGEX = /^([0-9a-f]{3}|[0-9a-f]{6})$/i

    attr_accessor :value

    def initialize(hex_color)
      self.value = hex_color
    end

    def valid?
      !!Iz::HexColor.is_hex_color?(value)
    end

    def self.is_hex_color?(value)
      val = value.to_s
      return false unless val[0] == '#'

      val[0] = ''
      val =~ REGEX
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
iz-0.3.0 lib/iz/hex_color.rb