Sha256: 2b070d385e0caec1c5b66ce6c0723f33d5e7e29648df2a3f2333f1c4e85106b8

Contents?: true

Size: 636 Bytes

Versions: 7

Compression:

Stored size: 636 Bytes

Contents

module Iroki
  module CoreExt
    module String

      def hex? str
        str.match(/^#[0-9A-Fa-f]{6}$/)
      end

      def clean str
        str.gsub(/[^\p{Alnum}_]+/, "_").gsub(/_+/, "_")
      end

      def has_color? name
        name.match(/(.*)(\[&!color="#[0-9A-Fa-f]{6}"\])/)
      end
      alias already_checked? has_color?

      def clean_name name
        if name.nil?
          nil
        else
          if (match = has_color? name)
            name = match[1]
            color = match[2]

            clean(name) + color
          else
            clean(name)
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
iroki-0.0.7 lib/iroki/core_ext/string/string.rb
iroki-0.0.6 lib/iroki/core_ext/string/string.rb
iroki-0.0.5 lib/iroki/core_ext/string/string.rb
iroki-0.0.4 lib/iroki/core_ext/string/string.rb
iroki-0.0.3 lib/iroki/core_ext/string/string.rb
iroki-0.0.2 lib/iroki/core_ext/string/string.rb
iroki-0.0.1 lib/iroki/core_ext/string/string.rb