Module: Parse

Extended by:
Parse
Included in:
Parse
Defined in:
lib/poisol/utils/parse.rb

Instance Method Summary collapse

Instance Method Details

#hash_array_to_column_hash(hash_array) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/poisol/utils/parse.rb', line 17

def hash_array_to_column_hash hash_array
  return [] if hash_array.blank?
  column_hash = Hash.new
  hash_array[0].each_key { |key| column_hash.merge!(key=>[])}
  hash_array.each do |hash|
    column_hash.each_key {|key| column_hash[key].append hash[key]}
  end
  column_hash
end

#hash_to_concatenated_key_value(hash) ⇒ Object



27
28
29
# File 'lib/poisol/utils/parse.rb', line 27

def hash_to_concatenated_key_value hash
  RestClient::Utils.encode_query_string hash
end

#json_file_to_hash(file_name) ⇒ Object



4
5
6
# File 'lib/poisol/utils/parse.rb', line 4

def json_file_to_hash file_name
  JSON.parse File.read(file_name)
end

#json_to_hash(json) ⇒ Object



13
14
15
# File 'lib/poisol/utils/parse.rb', line 13

def json_to_hash json
  JSON.parse json
end

#yaml_file(file_name) ⇒ Object



8
9
10
11
# File 'lib/poisol/utils/parse.rb', line 8

def yaml_file file_name
  require 'yaml'
  YAML.load_file(file_name)
end