module Reittiopas2::Utilities
Public Instance Methods
convert_array_values(hash)
click to toggle source
Converts array values into string values containing array members joined by pipe (‘|’) characters.
@param [Hash] a hash @return [Hash] a hash
# File lib/reittiopas2/utilities.rb, line 10 def convert_array_values(hash) result = hash.map do |key, value| if value.is_a? Array [key, value.join('|')] else [key, value] end end Hash[result] end
select_keys(hash, keys)
click to toggle source
# File lib/reittiopas2/utilities.rb, line 22 def select_keys(hash, keys) hash.select do |key, value| keys.include? key end end