Class: Object

Inherits:
BasicObject
Defined in:
lib/spoonacular/querify.rb

Instance Method Summary collapse

Instance Method Details

#querifyObject



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/spoonacular/querify.rb', line 3

def querify
	if self.is_a? String
		return self.gsub(/,\s?/, "%2C").gsub(" ", "+")
	elsif self.is_a? Array
		return self.join("%2C").gsub(" ", "+")
	elsif self.is_a? Hash
		result = []
		self.each do |key, value|
			result << "#{key.to_s.to_camel_case}=#{value.querify}"
		end
		return result.join("&")
	end
end

#to_camel_caseObject



17
18
19
20
21
22
23
24
# File 'lib/spoonacular/querify.rb', line 17

def to_camel_case
	self.chars.length.times do |i|
		if self[i] == "_"
			self[i+1] = self[i+1].upcase
		end
	end
	return self.delete "_"
end