Sha256: 5e2fc44d4553344b90caa451c6623b8411a8806b2f81d19eafed77bed9cf9f8b

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

require 'jaspion/kilza/version'

require 'jaspion/kilza/source'
require 'jaspion/kilza/class'
require 'jaspion/kilza/property'
require 'jaspion/kilza/language'
require 'jaspion/kilza/language/objc'
require 'jaspion/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 Jaspion
  module Kilza
    # Removes everything except numbers and letters.
    #
    # @param str [String] string to be cleaned
    #
    # @return [String] cleaned string
    def self.clean(str)
      return if str.nil?
      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)
      return if str.nil?
      Jaspion::Kilza.clean(str).downcase
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jaspion-kilza-1.0.9 lib/jaspion/kilza.rb