Class: Fb::Page
- Inherits:
-
Object
- Object
- Fb::Page
- Defined in:
- lib/fb/page.rb
Overview
Fb::Page reprensents a Facebook page. Provides methods to get/set a page’s name and id.
Instance Attribute Summary collapse
-
#id ⇒ String
readonly
The unique id of the page.
-
#name ⇒ String
readonly
The name of the page.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Page
constructor
A new instance of Page.
-
#insights(options = {}) ⇒ Hash
A collection of metrics with metric name as key and metric object as value.
-
#to_s ⇒ String
The representation of the page.
Constructor Details
#initialize(options = {}) ⇒ Page
Returns a new instance of Page.
16 17 18 19 20 |
# File 'lib/fb/page.rb', line 16 def initialize( = {}) @name = ["name"] @id = ["id"] @user = ["user"] end |
Instance Attribute Details
#id ⇒ String (readonly)
Returns the unique id of the page.
11 12 13 |
# File 'lib/fb/page.rb', line 11 def id @id end |
#name ⇒ String (readonly)
Returns the name of the page.
8 9 10 |
# File 'lib/fb/page.rb', line 8 def name @name end |
Instance Method Details
#insights(options = {}) ⇒ Hash
Returns a collection of metrics with metric name as key and metric object as value.
36 37 38 39 40 |
# File 'lib/fb/page.rb', line 36 def insights( = {}) fetch_insights()["data"].map do |metric_data| [metric_data["name"], Fb::Metric.new(metric_data)] end.to_h end |
#to_s ⇒ String
Returns the representation of the page.
43 44 45 |
# File 'lib/fb/page.rb', line 43 def to_s "#<#{self.class.name} id=#{@id}, name=#{@name}>" end |