Sha256: b1516404d48cd941a88df951bf6a3e717003f14b9d5e717939f7b4cdc7ede1ad

Contents?: true

Size: 899 Bytes

Versions: 3

Compression:

Stored size: 899 Bytes

Contents

require 'kilza/version'

require 'kilza/source'
require 'kilza/class'
require 'kilza/property'
require 'kilza/language'
require 'kilza/language/objc'
require 'kilza/language/java'

# Ruby class
class String
  # Test if the string can be a number
  #
  # @param str [String] string to be tested
  #
  # @return [Boolean] true in case of success
  def number?
    true if Float(self) rescue false
  end
end

# Tranforms a JSON string into Objects
module Kilza
  # Removes everything except numbers and letters.
  #
  # @param str [String] string to be cleaned
  #
  # @return [String] cleaned string
  def self.clean(str)
    str = '_' + str if str[0].number?
    str.gsub(/[^a-zA-Z0-9]/, '_')
  end

  # Cleans the string and make it lowercase.
  #
  # @param str [String] string to be cleaned
  #
  # @return [String] cleaned string
  def self.normalize(str)
    Kilza.clean(str).downcase
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kilza-1.0.7 lib/kilza.rb
kilza-1.0.6 lib/kilza.rb
kilza-1.0.4 lib/kilza.rb