Sha256: 0cec4cea85656cb5e4a681957f2ec121150144ebfa47d403049a3583f8be948c
Contents?: true
Size: 953 Bytes
Versions: 6
Compression:
Stored size: 953 Bytes
Contents
module Quandl class Util def self.methodize(string) string.gsub(/\./, '').parameterize.gsub(/\-/, '_') end def self.convert_to_dates(hash) return hash unless hash.is_a?(Hash) hash.update(hash) do |_k, v| if v.is_a?(String) && v =~ /^\d{4}-\d{2}-\d{2}$/ # Date Date.parse(v) elsif v.is_a?(String) && v =~ /^\d{4}-\d{2}-\d{2}T[\d:\.]+Z/ # DateTime Time.parse(v) elsif v.is_a?(Array) v.map { |ao| convert_to_dates(ao) } elsif v.is_a?(Hash) convert_to_dates(v) else v end end hash end def self.constructed_path(path, params = {}) params ||= {} sub_params = Hash[{ id: nil }.merge(params).map { |k, v| [':' + k.to_s, v] }] params.delete_if { |key, _value| path =~ /:#{key}/ } path = path.dup path.gsub!(Regexp.union(sub_params.keys), sub_params) path end end end
Version data entries
6 entries across 6 versions & 1 rubygems