Sha256: 6409ffc815a760e5738e545d2c8720e55304f8e906f2ad1ac7cbe451e55c757d

Contents?: true

Size: 530 Bytes

Versions: 3

Compression:

Stored size: 530 Bytes

Contents

# frozen_string_literal: true

class String
  alias lpartition partition

  def camelcase
    split("_").map { |s| "#{s[0].to_s.upcase}#{s[1..-1]}" }.join("")
  end

  alias camelize camelcase

  def snakecase
    gsub(/[A-Z\s-]/) { |s, t| "_#{s}" }[1..-1].to_s.downcase
  end
  
  alias snakefy snakecase

  def rjust_blanks length
    rjust length, " "
  end

  def rjust_zeroes length
    rjust length, "0"
  end

  def ljust_blanks length
    ljust length, " "
  end

  def ljust_zeroes length
    ljust length, "0"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lizarb-1.0.4 lib/lizarb/ruby/string.rb
lizarb-1.0.3 lib/lizarb/ruby/string.rb
lizarb-1.0.2 lib/lizarb/ruby/string.rb