Class: SocialNetworking::Concerns::ProfilePage::Feed

Inherits:
Object
  • Object
show all
Defined in:
app/controllers/social_networking/concerns/profile_page/feed.rb

Overview

Displays feed data for profile page.

Constant Summary collapse

SHARED_ITEM_PAGE_SIZE =
10

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(participant_id:, page:) ⇒ Feed

Returns a new instance of Feed.



10
11
12
13
# File 'app/controllers/social_networking/concerns/profile_page/feed.rb', line 10

def initialize(participant_id:, page:)
  @participant_id = participant_id
  @page = page.try(:to_i) || 0
end

Instance Attribute Details

#pageObject (readonly)

Returns the value of attribute page.



7
8
9
# File 'app/controllers/social_networking/concerns/profile_page/feed.rb', line 7

def page
  @page
end

#participant_idObject (readonly)

Returns the value of attribute participant_id.



7
8
9
# File 'app/controllers/social_networking/concerns/profile_page/feed.rb', line 7

def participant_id
  @participant_id
end

Instance Method Details

#page_itemsObject



15
16
17
18
19
20
21
22
23
# File 'app/controllers/social_networking/concerns/profile_page/feed.rb', line 15

def page_items
  if feed_items.size >= start_index
    sorted_feed_items[
      start_index..(start_index + SHARED_ITEM_PAGE_SIZE - 1)
    ]
  else
    []
  end
end