Class: Arena::Feed

Inherits:
Base
  • Object
show all
Defined in:
lib/arena/feed.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#attrs

Instance Method Summary collapse

Methods inherited from Base

attr_reader, #initialize

Constructor Details

This class inherits a constructor from Arena::Base

Instance Attribute Details

#limitObject (readonly)

Returns the value of attribute limit.



7
8
9
# File 'lib/arena/feed.rb', line 7

def limit
  @limit
end

#offsetObject (readonly)

Returns the value of attribute offset.



7
8
9
# File 'lib/arena/feed.rb', line 7

def offset
  @offset
end

#range_endObject (readonly)

Returns the value of attribute range_end.



7
8
9
# File 'lib/arena/feed.rb', line 7

def range_end
  @range_end
end

#range_startObject (readonly)

Returns the value of attribute range_start.



7
8
9
# File 'lib/arena/feed.rb', line 7

def range_start
  @range_start
end

#totalObject (readonly)

Returns the value of attribute total.



7
8
9
# File 'lib/arena/feed.rb', line 7

def total
  @total
end

#typeObject (readonly)

Returns the value of attribute type.



7
8
9
# File 'lib/arena/feed.rb', line 7

def type
  @type
end

Instance Method Details

#groupsObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/arena/feed.rb', line 15

def groups
  if stories?
    groups = items.group_by do |item|
      target = "#{item.target.id}_" if !item.target.nil?

      "#{item.user.id}_#{target}#{item.action.gsub(' ', '_')}"
    end

    @groups ||=
      groups.collect { |key, stories| Arena::Group.new(key, stories) }.
        sort_by { |group| group.summary.indicative.created_at }.reverse!
  end
end

#storiesObject Also known as: items



9
10
11
# File 'lib/arena/feed.rb', line 9

def stories
  @stories ||= @attrs["items"].collect { |item| Arena::Story.new(item) } if stories?
end