Class: Nelumba::Collection

Inherits:
Object
  • Object
show all
Includes:
Object
Defined in:
lib/nelumba/collection.rb

Direct Known Subclasses

Feed

Constant Summary

Constants included from Object

Object::USERNAME_REGULAR_EXPRESSION

Instance Attribute Summary collapse

Attributes included from Object

#author, #content, #display_name, #html, #image, #published, #summary, #text, #title, #uid, #updated, #url

Instance Method Summary collapse

Methods included from Object

#mentions, #reply_to, #to_as1, #to_html, #to_json, #to_text

Constructor Details

#initialize(options = {}, &blk) ⇒ Collection

Returns a new instance of Collection.



8
9
10
# File 'lib/nelumba/collection.rb', line 8

def initialize(options = {}, &blk)
  init(options, &blk)
end

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items.



5
6
7
# File 'lib/nelumba/collection.rb', line 5

def items
  @items
end

#total_itemsObject (readonly)

Returns the value of attribute total_items.



6
7
8
# File 'lib/nelumba/collection.rb', line 6

def total_items
  @total_items
end

Instance Method Details

#init(options = {}, &blk) ⇒ Object



12
13
14
15
16
17
# File 'lib/nelumba/collection.rb', line 12

def init(options = {}, &blk)
  super(options, &blk)

  @items       = options[:items] || []
  @total_items = options[:total_items] || @items.count
end

#to_hashObject



19
20
21
22
23
24
# File 'lib/nelumba/collection.rb', line 19

def to_hash
  {
    :items       => (self.items || []).dup,
    :total_items => self.total_items || self.items.count
  }.merge(super)
end

#to_json_hashObject



26
27
28
29
30
31
32
# File 'lib/nelumba/collection.rb', line 26

def to_json_hash
  {
    :objectType => "collection",
    :items      => (self.items || []).dup,
    :totalItems => self.total_items || self.items.count
  }.merge(super)
end