Sha256: d394ba53ed2d9911cf1b184ad45b174d7de1e371c57d575293ccae9690241704

Contents?: true

Size: 286 Bytes

Versions: 1

Compression:

Stored size: 286 Bytes

Contents

class String
  def snake_case
    gsub("::", "/")
    gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
      gsub(/([a-z\d])([A-Z])/, '\1_\2').
      tr("-", "_").downcase
  end

  def camelcase
    return self if self !~ /_/ && self =~ /[A-Z]+.*/
    split("_").map(&:capitalize).join
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
grimm-0.0.5 lib/grimm/utilities.rb