Module: Gassy::GassyUtils
- Defined in:
- lib/gassy/gassy_utils.rb
Class Method Summary collapse
-
.condense_xml(file) ⇒ Object
Condense the provided XML file by removing all spaces and new lines.
-
.method_missing(name, *args) ⇒ Object
Automatically generate methods that returns data for the Entities listed in the Gassy::GassyConstants::ENTITIES array.
-
.rename(file, old_name, new_name) ⇒ Object
Simple string substitution method alias .
Class Method Details
.condense_xml(file) ⇒ Object
Condense the provided XML file by removing all spaces and new lines
Example:
>> condensed = GassyUtils.condense_xml(file)
12 13 14 15 16 17 |
# File 'lib/gassy/gassy_utils.rb', line 12 def self.condense_xml(file) file = file.gsub(/\r/,"") file = file.gsub(/\n/,"") file = file.gsub(/\t/,"") file = file.gsub(/\s+/,"") end |
.method_missing(name, *args) ⇒ Object
Automatically generate methods that returns data for the Entities listed in the Gassy::GassyConstants::ENTITIES array.
Example:
>> array_of_city_names = GassyUtils.cities
33 34 35 36 |
# File 'lib/gassy/gassy_utils.rb', line 33 def self.method_missing(name, *args) super unless GassyConstants::ENTITIES.include?(name.to_s) eval("GassyConstants::#{name.upcase}") end |
.rename(file, old_name, new_name) ⇒ Object
Simple string substitution method alias
Example:
>> file_with_renamed_entry = GassyUtils.rename(file, "Joe", "Sam")
24 25 26 |
# File 'lib/gassy/gassy_utils.rb', line 24 def self.rename(file, old_name, new_name) file.sub(old_name, new_name) end |