class FbookGraph::Friend

Public Class Methods

all(search_options, options: {}) click to toggle source
# File lib/fbook_graph/friend.rb, line 5
def all(search_options, options: {})
  request = Request.new(options)
  data = request.parsed_response['friends']['data']

  friends = data.map { |friend| friend['name'].downcase }

  search_options.each do |key, value|
    case key
    when :start_with
      friends = friends.select { |friend| friend.start_with? value.downcase }
    when :end_with
      friends = friends.select { |friend| friend.end_with? value.downcase }
    end
  end
  friends
end