Class: FaceGroups::Group

Inherits:
Object
  • Object
show all
Defined in:
lib/facegroups/group.rb

Overview

Main class to setup a Facebook group

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(group_data:) ⇒ Group

Returns a new instance of Group.



10
11
12
13
14
# File 'lib/facegroups/group.rb', line 10

def initialize(group_data:)
  @name = group_data['name']
  @id = group_data['id']
  @feed = Feed.new(feed_data: group_data['feed'])
end

Instance Attribute Details

#feedObject (readonly)

Returns the value of attribute feed.



8
9
10
# File 'lib/facegroups/group.rb', line 8

def feed
  @feed
end

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/facegroups/group.rb', line 8

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/facegroups/group.rb', line 8

def name
  @name
end

Class Method Details

.find(id:) ⇒ Object



16
17
18
19
# File 'lib/facegroups/group.rb', line 16

def self.find(id:)
  group_data = FbApi.group_data(id)
  group_data.include?('error') ? nil : new(group_data: group_data)
end

Instance Method Details

#latest_postingsObject



21
22
23
# File 'lib/facegroups/group.rb', line 21

def latest_postings
  FbApi.newest_group_postings(id)
end