Sha256: 5db56e096e3f06413a78221b39424dfaadd4b3a4c216bc935c456788b713fea8

Contents?: true

Size: 512 Bytes

Versions: 16

Compression:

Stored size: 512 Bytes

Contents

class String
  alias each each_line

  def clean_quote
    if index(/["\s]/)
      %{"#{tr('"', "'")}"}
    else
      self
    end
  end

  # from: http://rubydoc.info/gems/extlib/0.9.15/String#camel_case-instance_method
  def camel_case
    return self if self !~ /_/ && self =~ /[A-Z]+.*/
    split('_').map{|e| e.capitalize}.join
  end

  def snake_case
    return downcase if match(/\A[A-Z]+\z/)
    gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
        gsub(/([a-z])([A-Z])/, '\1_\2').
        downcase
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
liquid-ext-3.5.3 lib/liquid/ext/string.rb
liquid-ext-3.5.2 lib/liquid/ext/string.rb
liquid-ext-3.5.0 lib/liquid/ext/string.rb
liquid-ext-3.4.2 lib/liquid/ext/string.rb
liquid-ext-3.4.1 lib/liquid/ext/string.rb
liquid-ext-3.4.0 lib/liquid/ext/string.rb
liquid-ext-3.3.10 lib/liquid/ext/string.rb
liquid-ext-3.3.9 lib/liquid/ext/string.rb
liquid-ext-3.3.8 lib/liquid/ext/string.rb
liquid-ext-3.3.7 lib/liquid/ext/string.rb
liquid-ext-3.3.6 lib/liquid/ext/string.rb
liquid-ext-3.3.5 lib/liquid/ext/string.rb
liquid-ext-3.3.4 lib/liquid/ext/string.rb
liquid-ext-3.3.3 lib/liquid/ext/string.rb
liquid-ext-3.3.2 lib/liquid/ext/string.rb
liquid-ext-3.3.0 lib/liquid/ext/string.rb