Sha256: da91555a91b0d6b73bfce65b577915ce03efae34c3a4eff7ee1e8736b35ba857

Contents?: true

Size: 1018 Bytes

Versions: 1

Compression:

Stored size: 1018 Bytes

Contents

#
# Utility classes used by GassyUtils
#
module Gassy
  module GassyUtils

    # Condense the provided XML file by removing all spaces and new lines
    #
    # Example:
    #   >> condensed = GassyUtils.condense_xml(file)
    #
    def self.condense_xml(file)
      file = file.gsub(/\r/,"")
      file = file.gsub(/\n/,"")
      file = file.gsub(/\t/,"")
      file = file.gsub(/\s+/,"")
    end
  
    # Simple string substitution method alias 
    #
    # Example:
    #   >> file_with_renamed_entry = GassyUtils.rename(file, "Joe", "Sam")
    #
    def self.rename(file, old_name, new_name)
      file.sub(old_name, new_name)  
    end

    # Automatically generate methods that returns data for the Entities listed in the Gassy::GassyConstants::ENTITIES array. 
    #
    # Example:
    #   >> array_of_city_names = GassyUtils.cities
    #
    def self.method_missing(name, *args)
      super unless GassyConstants::ENTITIES.include?(name.to_s)
        eval("GassyConstants::#{name.upcase}")
    end
  
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gassy-1.0.0 lib/gassy/gassy_utils.rb