module Seahorse::Util

def irregular_inflections(hash)

Other tags:
    Api: - private
def irregular_inflections(hash)
  @irregular_inflections.update(hash)
  @irregular_regex = Regexp.new(@irregular_inflections.keys.join('|'))
end

def load_json(path)

def load_json(path)
  MultiJson.load(File.open(path, 'r', encoding: 'UTF-8') { |f| f.read })
end

def underscore(string)

Returns:
  • (String) - Returns the underscored version of the given string.

Parameters:
  • string (String) --
def underscore(string)
  string.
    gsub(@irregular_regex) { |word| '_' + @irregular_inflections[word] }.
    gsub(/([A-Z0-9]+)([A-Z][a-z])/, '\1_\2').
    scan(/[a-z0-9]+|\d+|[A-Z0-9]+[a-z]*/).
    join('_').downcase
end

def uri_escape(string)

def uri_escape(string)
  CGI::escape(string.encode('UTF-8')).gsub('+', '%20').gsub('%7E', '~')
end