Class: NounProjectApi::Collection

Inherits:
BaseItem
  • Object
show all
Defined in:
lib/noun-project-api/collection.rb

Overview

A single Collection as an abstracted ruby object.

Constant Summary collapse

ITEM_NAME =
"collection".freeze

Instance Attribute Summary

Attributes inherited from BaseItem

#original_hash

Instance Method Summary collapse

Methods inherited from BaseItem

#id, #initialize, #to_json

Constructor Details

This class inherits a constructor from NounProjectApi::BaseItem

Instance Method Details

#author_idObject



8
9
10
# File 'lib/noun-project-api/collection.rb', line 8

def author_id
  original_hash["author_id"].to_i
end

#author_nameObject



12
13
14
# File 'lib/noun-project-api/collection.rb', line 12

def author_name
  original_hash["author"]["name"]
end

#icon_countObject



16
17
18
# File 'lib/noun-project-api/collection.rb', line 16

def icon_count
  original_hash["icon_count"].to_i
end

#is_published?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/noun-project-api/collection.rb', line 20

def is_published?
  original_hash["is_published"].to_i == 1
end

#to_hashObject



24
25
26
27
28
29
30
31
32
# File 'lib/noun-project-api/collection.rb', line 24

def to_hash
  {
    id: id,
    author_id: author_id,
    author_name: author_name,
    icon_count: icon_count,
    is_published: is_published?
  }
end