Sha256: 590858e3dc7843e150352b1bad04c529f57829ac7908b48e7751c0f95e5e5fe5

Contents?: true

Size: 788 Bytes

Versions: 5

Compression:

Stored size: 788 Bytes

Contents

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

module FansWatch 
  # Single posting on group's feed 
  class Posting 
    attr_reader :message, :created_time, :id, :attachment
    
    def initialize(data: nil) 
      load_data(data)
    end

    def attachment 
      return @attachment if @attachment
    
      attached_data = FbApi.posting_attachments(@id) 
    end 

    def self.find(id:)
      posting_data = FbApi.posting(id)
      new(data:posting_data)
    end

    private 

    def load_data(posting_data)
      @id = posting_data['id']
      @created_time = posting_data['created_time'] 
      @message = posting_data['message']

      attached = attachment
      @attachment = Attachment.new(attached) if attached 
    end
  end 
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fanswatch-0.1.4 lib/fanswatch/posting.rb
fanswatch-0.1.3 lib/fanswatch/posting.rb
fanswatch-0.1.2 lib/fanswatch/posting.rb
fanswatch-0.1.1 lib/fanswatch/posting.rb
fanswatch-0.1.0 lib/fanswatch/posting.rb