lib/sportradar/api/data.rb in sportradar-api-0.1.38 vs lib/sportradar/api/data.rb in sportradar-api-0.9.0
- old
+ new
@@ -9,9 +9,25 @@
def all_attributes
self.instance_variables.map{|attribute| attribute.to_s.gsub('@', '').to_sym }
end
+ def parse_into_array(selector: , klass: )
+ if selector.is_a?(Array)
+ selector.map {|x| klass.new x }
+ elsif selector.is_a?(Hash)
+ [ klass.new(selector) ]
+ end
+ end
+
+ def parse_out_hashes(data_element)
+ if data_element && data_element.is_a?(Array)
+ data_element.find {|elem| elem.is_a?(Hash) }
+ else
+ data_element
+ end
+ end
+
end
end
end