Class: Funky::Page

Inherits:
GraphRootNode show all
Defined in:
lib/funky/page.rb

Instance Attribute Summary

Attributes inherited from GraphRootNode

#data

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from GraphRootNode

#id, #initialize

Constructor Details

This class inherits a constructor from Funky::GraphRootNode

Class Method Details

.where(id:) ⇒ Array<Funky::Page>

Fetches the data from Facebook’s APIs and instantiates the data into an Array of Funky::Page objects. It can accept one page ID or an array of multiple page IDs.

Examples:

Getting one page

id = '10153834590672139'
Funky::Page.where(id: id) # => [#<Funky::Page>]

Getting multiple videos

ids = ['10154439119663508', '10153834590672139']
Funky::Page.where(id: ids) # => [#<Funky::Page>, #<Funky::Page>]

Returns:

  • (Array<Funky::Page>)

    multiple instances of Funky::Page objects containing data obtained by Facebook’s APIs.



85
86
87
88
# File 'lib/funky/page.rb', line 85

def self.where(id:)
  return nil unless id
  instantiate_collection(fetch_and_parse_data Array(id))
end

Instance Method Details

#cityString?

Returns the city of the Facebook Page if it is present.

Returns:

  • (String, nil)

    the city of the Facebook Page if it is present

See Also:



32
33
34
# File 'lib/funky/page.rb', line 32

def city
  location[:city]
end

#countryString?

Returns the country of the Facebook Page if it is present.

Returns:

  • (String, nil)

    the country of the Facebook Page if it is present

See Also:



50
51
52
# File 'lib/funky/page.rb', line 50

def country
  location[:country]
end

#latitudeFixnum?

Returns the latitude of the Facebook Page if it is present.

Returns:

  • (Fixnum, nil)

    the latitude of the Facebook Page if it is present

See Also:



62
63
64
# File 'lib/funky/page.rb', line 62

def latitude
  location[:latitude]
end

#locationHash

Note:

location is a Hash that contains more specific properties such as city, state, zip, etc.

Returns the location of the Facebook Page if it is present.

Returns:

  • (Hash)

    the location of the Facebook Page if it is present

See Also:



26
27
28
# File 'lib/funky/page.rb', line 26

def location
  data.fetch(:location, {})
end

#longitudeFixnum?

Returns the longitude of the Facebook Page if it is present.

Returns:

  • (Fixnum, nil)

    the longitude of the Facebook Page if it is present

See Also:



68
69
70
# File 'lib/funky/page.rb', line 68

def longitude
  location[:longitude]
end

#nameString

Note:

For example, for www.facebook.com/platform the name is ‘Facebook For Developers’.

Returns the name of the Facebook Page.

Returns:

  • (String)

    the name of the Facebook Page.

See Also:



17
18
19
# File 'lib/funky/page.rb', line 17

def name
  data[:name]
end

#stateString?

Returns the state of the Facebook Page if it is present.

Returns:

  • (String, nil)

    the state of the Facebook Page if it is present

See Also:



44
45
46
# File 'lib/funky/page.rb', line 44

def state
  location[:state]
end

#streetString?

Returns the street of the Facebook Page if it is present.

Returns:

  • (String, nil)

    the street of the Facebook Page if it is present

See Also:



38
39
40
# File 'lib/funky/page.rb', line 38

def street
  location[:street]
end

#usernameString

Note:

For example, for www.facebook.com/platform the username is ‘platform’.

Returns the alias of the Facebook Page.

Returns:

  • (String)

    the alias of the Facebook Page.

See Also:



8
9
10
# File 'lib/funky/page.rb', line 8

def username
  data[:username]
end

#zipString

Returns the zip code of the Facebook Page if it is present.

Returns:

  • (String)

    the zip code of the Facebook Page if it is present

See Also:



56
57
58
# File 'lib/funky/page.rb', line 56

def zip
  location[:zip]
end