Module: NCSAParser::Helper

Defined in:
lib/ncsa-parser/helper.rb

Class Method Summary collapse

Class Method Details

.clean_uri(uri) ⇒ Object



4
5
6
7
8
9
# File 'lib/ncsa-parser/helper.rb', line 4

def self.clean_uri(uri)
  uri.
    gsub(/ /, '+').
    gsub(/\\"/, '%22').
    gsub(/,/, '%2C')
end

.deep_symbolize_keys(hash) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/ncsa-parser/helper.rb', line 11

def self.deep_symbolize_keys(hash)
  hash.inject({}) do |memo, (key, value)|
    key = key.to_sym if key.respond_to?(:to_sym) rescue :nil
    value = NCSAHelper.deep_symbolize_keys(value) if value.is_a?(Hash)
    memo[key] = value
    memo
  end
end