Sha256: bb9c13c3d582a0d3c71238a0e0717c3dfd50149fe16124fbe57b5827e58993a7

Contents?: true

Size: 837 Bytes

Versions: 8

Compression:

Stored size: 837 Bytes

Contents

# frozen_string_literal: true
require_relative 'fb_api'
require_relative 'attachment'

module FaceGroups
  # Single posting on group's feed
  class Posting
    attr_reader :id, :created_time, :updated_time, :message, :name, :attachment

    def initialize(data: nil)
      load_data(data)
    end

    def self.find(id:)
      posting_data = FaceGroups::FbApi.posting_data(id)
      posting_data.keys.include?('error') ? nil : new(data: posting_data)
    end

    private

    def load_data(posting_data)
      @id = posting_data['id']
      @updated_time = posting_data['updated_time']
      @created_time = posting_data['created_time']
      @name = posting_data['message']
      @message = posting_data['message']
      attached = posting_data['attachments']
      @attachment = Attachment.new(attached) if attached
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
facegroups-0.6.2 lib/facegroups/posting.rb
facegroups-0.6.1 lib/facegroups/posting.rb
facegroups-0.6.0 lib/facegroups/posting.rb
facegroups-0.5.0 lib/facegroups/posting.rb
facegroups-0.4.1 lib/facegroups/posting.rb
facegroups-0.4.0 lib/facegroups/posting.rb
facegroups-0.3.0 lib/facegroups/posting.rb
facegroups-0.2.2 lib/facegroups/posting.rb