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.



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

def limit
  @limit
end

#offsetObject (readonly)

Returns the value of attribute offset.



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

def offset
  @offset
end

#range_endObject (readonly)

Returns the value of attribute range_end.



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

def range_end
  @range_end
end

#range_startObject (readonly)

Returns the value of attribute range_start.



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

def range_start
  @range_start
end

#totalObject (readonly)

Returns the value of attribute total.



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

def total
  @total
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#groupsObject



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

def groups
  return unless stories?

  groups = items.group_by do |item|
    target = "#{item.target.id}_" unless 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

#storiesObject Also known as: items



11
12
13
# File 'lib/arena/feed.rb', line 11

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