class DaFace::Datasift::Links

Public Class Methods

get_elements(data={}) click to toggle source
# File lib/da_face/datasift/links.rb, line 10
def self.get_elements data={}
  hashed_links = []
  unless data.empty?
    data.values.first.size.times do |index|
      hashed_links << get_values(index - 1, data.keys, data)
    end
  end
  return hashed_links
end
get_values(index, keys, hash) click to toggle source

Recursively search the hash for elements of index 'index' from the arrays inside the hashes.

# File lib/da_face/datasift/links.rb, line 22
def self.get_values index, keys, hash
  new_hash = {}
  keys.each do |key|
    if hash[key].kind_of? Hash
      new_hash[key] = get_values(index, hash[key].keys, hash[key])
    else
      new_hash[key] = hash[key][index]
    end
  end
  
  return new_hash
end
new(data={}) click to toggle source
# File lib/da_face/datasift/links.rb, line 4
def initialize data={}
  self.class.get_elements(data).each do |e|
    self << DaFace::Datasift::Link.new(e)
  end
end