Sha256: 0ec3c97331977dc3ff17efd4223ef03ac94dec4aff3daf5f1ce3c4a0d1e9324f

Contents?: true

Size: 1.19 KB

Versions: 20

Compression:

Stored size: 1.19 KB

Contents

module Iroki
  module CoreExt
    module String

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

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

      def clean
        # puts %Q{clean: #{self}, #{self.gsub(/'/, '"')}}
        self.gsub(/'/, '"')
      end

      def single_quote
        if self.match /\A'.*'\Z/
          # puts %Q{single_quote if: #{self}, outputing #{self.dup}}
          self.dup
        else
          # puts %Q{single_quote else: #{self}, returning '#{self.clean}'}
          %Q['#{self.clean}']
        end
      end

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

          # puts %Q{clean_name if: #{self}, returning #{name.single_quote + color}}
          name.single_quote + color
          # name + color
        else
          # puts %Q{clean_name else: #{self}, returning #{self.single_quote}}
          self.single_quote
        end
      end

      def clean_strict
        self.strip.gsub(/[^\p{Alnum}_]+/, "_").gsub(/_+/, "_")
      end


      def has_single_quote?
        self.match(/'/)
      end

    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
iroki-0.0.35 lib/iroki/core_ext/string/string.rb
iroki-0.0.34 lib/iroki/core_ext/string/string.rb
iroki-0.0.33 lib/iroki/core_ext/string/string.rb
iroki-0.0.32 lib/iroki/core_ext/string/string.rb
iroki-0.0.31 lib/iroki/core_ext/string/string.rb
iroki-0.0.30 lib/iroki/core_ext/string/string.rb
iroki-0.0.29 lib/iroki/core_ext/string/string.rb
iroki-0.0.28 lib/iroki/core_ext/string/string.rb
iroki-0.0.27 lib/iroki/core_ext/string/string.rb
iroki-0.0.26 lib/iroki/core_ext/string/string.rb
iroki-0.0.25 lib/iroki/core_ext/string/string.rb
iroki-0.0.24 lib/iroki/core_ext/string/string.rb
iroki-0.0.23 lib/iroki/core_ext/string/string.rb
iroki-0.0.22 lib/iroki/core_ext/string/string.rb
iroki-0.0.21 lib/iroki/core_ext/string/string.rb
iroki-0.0.20 lib/iroki/core_ext/string/string.rb
iroki-0.0.19 lib/iroki/core_ext/string/string.rb
iroki-0.0.18 lib/iroki/core_ext/string/string.rb
iroki-0.0.17 lib/iroki/core_ext/string/string.rb
iroki-0.0.16 lib/iroki/core_ext/string/string.rb