Class: Gliffy::BaseParser
- Inherits:
-
Object
- Object
- Gliffy::BaseParser
show all
- Defined in:
- lib/gliffy/response.rb
Overview
Class Method Summary
collapse
Class Method Details
.add_boolean(root, name) ⇒ Object
200
201
202
|
# File 'lib/gliffy/response.rb', line 200
def self.add_boolean(root,name)
root[name + "?"] = root[name] == 'true'
end
|
.add_date(root, name) ⇒ Object
204
205
206
207
208
|
# File 'lib/gliffy/response.rb', line 204
def self.add_date(root,name)
if root[name]
root[name] = Time.at(root[name].to_i / 1000) unless root[name].kind_of? Time
end
end
|
.add_int(root, name, new_name = nil) ⇒ Object
194
195
196
197
198
|
# File 'lib/gliffy/response.rb', line 194
def self.add_int(root,name,new_name=nil)
if root[name]
root[new_name.nil? ? name : new_name] = root[name].to_i
end
end
|
.as_array(item) ⇒ Object
Returns the item as an array, or nil if it was nil
186
187
188
189
190
191
192
|
# File 'lib/gliffy/response.rb', line 186
def self.as_array(item)
if item.nil?
nil
else
[item].flatten
end
end
|
.from_http_response(root) ⇒ Object
177
178
179
180
181
182
183
|
# File 'lib/gliffy/response.rb', line 177
def self.from_http_response(root)
params = Hash.new
root.each do |key,value|
params[key.to_sym] = value
end
Response.new(params)
end
|