Class: FbookGraph::Friend

Inherits:
Object
  • Object
show all
Defined in:
lib/fbook_graph/friend.rb

Class Method Summary collapse

Class Method Details

.all(search_options, options: {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 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