module Iroki::CoreExt::String

Public Instance Methods

already_checked?()
Alias for: has_color?
clean() click to toggle source
# File lib/iroki/core_ext/string/string.rb, line 14
def clean
  self.gsub(/'/, '"')
end
clean_name() click to toggle source
# File lib/iroki/core_ext/string/string.rb, line 26
def clean_name
  if (match = self.has_color?)
    name = match[1]
    color = match[2]

    name.single_quote + color
  else
    self.single_quote
  end
end
clean_strict() click to toggle source
# File lib/iroki/core_ext/string/string.rb, line 37
def clean_strict
  self.strip.gsub(/[^\p{Alnum}_]+/, "_").gsub(/_+/, "_")
end
has_color?() click to toggle source
# File lib/iroki/core_ext/string/string.rb, line 5
def has_color?
  self.match(/(.*)(\[&!color="#[0-9A-Fa-f]{6}"\])/)
end
Also aliased as: already_checked?
has_single_quote?() click to toggle source
# File lib/iroki/core_ext/string/string.rb, line 41
def has_single_quote?
  self.match(/'/)
end
hex?() click to toggle source
# File lib/iroki/core_ext/string/string.rb, line 10
def hex?
  self.match(/^#[0-9A-Fa-f]{6}$/)
end
single_quote() click to toggle source
# File lib/iroki/core_ext/string/string.rb, line 18
def single_quote
  if self.match /\A'.*'\Z/
    self.dup
  else
    %Q['#{self.clean}']
  end
end