Class: NHApi::Doujin
- Inherits:
-
Object
- Object
- NHApi::Doujin
- Defined in:
- lib/nh_api/doujin.rb
Instance Attribute Summary collapse
-
#cover ⇒ Object
readonly
Returns the value of attribute cover.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#media_id ⇒ Object
readonly
Returns the value of attribute media_id.
-
#num_favorites ⇒ Object
readonly
Returns the value of attribute num_favorites.
-
#num_pages ⇒ Object
readonly
Returns the value of attribute num_pages.
-
#pages ⇒ Object
readonly
Returns the value of attribute pages.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#thumbnail ⇒ Object
readonly
Returns the value of attribute thumbnail.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#upload_date ⇒ Object
readonly
Returns the value of attribute upload_date.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Doujin
constructor
A new instance of Doujin.
- #related ⇒ Object
Constructor Details
#initialize(attributes) ⇒ Doujin
Returns a new instance of Doujin.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/nh_api/doujin.rb', line 10 def initialize(attributes) @id = attributes["id"] @media_id = attributes["media_id"] @title = attributes["title"] @pages = build_pages(attributes["images"]["pages"]) @thumbnail = NHApi::Thumbnail.new(attributes["images"]["thumbnail"].merge(media_id: media_id)) @cover = NHApi::Cover.new(attributes["images"]["cover"].merge(media_id: media_id)) @upload_date = attributes["upload_date"] @tags = attributes["tags"] @num_pages = attributes["num_pages"] @num_favorites = attributes["num_favorites"] end |
Instance Attribute Details
#cover ⇒ Object (readonly)
Returns the value of attribute cover.
8 9 10 |
# File 'lib/nh_api/doujin.rb', line 8 def cover @cover end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/nh_api/doujin.rb', line 8 def id @id end |
#media_id ⇒ Object (readonly)
Returns the value of attribute media_id.
8 9 10 |
# File 'lib/nh_api/doujin.rb', line 8 def media_id @media_id end |
#num_favorites ⇒ Object (readonly)
Returns the value of attribute num_favorites.
8 9 10 |
# File 'lib/nh_api/doujin.rb', line 8 def num_favorites @num_favorites end |
#num_pages ⇒ Object (readonly)
Returns the value of attribute num_pages.
8 9 10 |
# File 'lib/nh_api/doujin.rb', line 8 def num_pages @num_pages end |
#pages ⇒ Object (readonly)
Returns the value of attribute pages.
8 9 10 |
# File 'lib/nh_api/doujin.rb', line 8 def pages @pages end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
8 9 10 |
# File 'lib/nh_api/doujin.rb', line 8 def @tags end |
#thumbnail ⇒ Object (readonly)
Returns the value of attribute thumbnail.
8 9 10 |
# File 'lib/nh_api/doujin.rb', line 8 def thumbnail @thumbnail end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
8 9 10 |
# File 'lib/nh_api/doujin.rb', line 8 def title @title end |
#upload_date ⇒ Object (readonly)
Returns the value of attribute upload_date.
8 9 10 |
# File 'lib/nh_api/doujin.rb', line 8 def upload_date @upload_date end |
Class Method Details
.all(page = 1) ⇒ Object
29 30 31 32 33 |
# File 'lib/nh_api/doujin.rb', line 29 def self.all(page = 1) response = Faraday.get("#{API_URL}galleries/all?page=#{page}") doujins = JSON.parse(response.body)["result"] doujins.map { |attributes| new(attributes) } end |
.find(id) ⇒ Object
23 24 25 26 27 |
# File 'lib/nh_api/doujin.rb', line 23 def self.find(id) response = Faraday.get("#{API_URL}/gallery/#{id}") attributes = JSON.parse(response.body) new(attributes) end |