module IrokiLib::CoreExt::String

Public Instance Methods

already_checked?(name)
Alias for: has_color?
clean(str) click to toggle source
# File lib/iroki_lib/core_ext/string/string.rb, line 9
def clean str
  str.gsub(/[^\p{Alnum}_]+/, "_").gsub(/_+/, "_")
end
clean_name(name) click to toggle source
# File lib/iroki_lib/core_ext/string/string.rb, line 18
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
has_color?(name) click to toggle source
# File lib/iroki_lib/core_ext/string/string.rb, line 13
def has_color? name
  name.match(/(.*)(\[&!color="#[0-9A-Fa-f]{6}"\])/)
end
Also aliased as: already_checked?
hex?(str) click to toggle source
# File lib/iroki_lib/core_ext/string/string.rb, line 5
def hex? str
  str.match(/^#[0-9A-Fa-f]{6}$/)
end