class Array

Public Instance Methods

accumulate() click to toggle source
# File lib/socializer/scraper/extensions.rb, line 14
def accumulate
  flatten.compact.uniq
end
collect_as_hash() click to toggle source
# File lib/socializer/scraper/extensions.rb, line 7
def collect_as_hash
  raise StandardError, "Array is not a hash collection!" unless hash_collection?
  flatten.compact.each_with_object(Hash.new([])) do |h1,h|
    h1.each{|k,v| h[k] = (h[k] | [v]).accumulate }
  end
end
extract_options!() click to toggle source
# File lib/socializer/scraper/extensions.rb, line 22
def extract_options!
  last.is_a?(Hash) && last.instance_of?(Hash) ? pop : {}
end
hash_collection?() click to toggle source
# File lib/socializer/scraper/extensions.rb, line 3
def hash_collection?
  flatten.compact.reject{|v| v.is_a?(Hash)}.empty?
end
hashify_or_collect() click to toggle source
# File lib/socializer/scraper/extensions.rb, line 18
def hashify_or_collect
  hash_collection? ? collect_as_hash : accumulate
end