Sha256: 09b30ddb81466e31853a4adc075a4a782b2bd654f142f823ce336b982ff0c2c9

Contents?: true

Size: 647 Bytes

Versions: 1

Compression:

Stored size: 647 Bytes

Contents

# frozen_string_literal: true
require_relative 'fb_api'
require_relative 'feed'

module FaceGroups
  # Main class to setup a Facebook group
  class Group
    attr_reader :id, :name, :feed

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

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

    def latest_posting_time
      latest_postings = FbApi.newest_group_postings(id)
      Time.parse(latest_postings.first['updated_time'])
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
facegroups-0.5.0 lib/facegroups/group.rb