Class: RakutenWebService::Books::Resource

Inherits:
Resource
  • Object
show all
Defined in:
lib/rakuten_web_service/books/resource.rb

Direct Known Subclasses

Book, CD, DVD, ForeignBook, Game, Magazine, Software, Total

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#[], attribute, client, endpoint, #initialize, resource_name, search, set_parser, set_resource_name

Constructor Details

This class inherits a constructor from RakutenWebService::Resource

Class Method Details

.find_resource_by_genre_id(genre_id) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/rakuten_web_service/books/resource.rb', line 11

def self.find_resource_by_genre_id(genre_id)
  case genre_id
  when /^001/ then RWS::Books::Book
  when /^002/ then RWS::Books::CD
  when /^003/ then RWS::Books::DVD
  when /^004/ then RWS::Books::Software
  when /^005/ then RWS::Books::ForeignBook
  when /^006/ then RWS::Books::Game
  when /^007/ then RWS::Books::Magazine
  end
end

Instance Method Details

#genreObject Also known as: genres



23
24
25
26
27
# File 'lib/rakuten_web_service/books/resource.rb', line 23

def genre
  @genre ||= self.books_genre_id.split('/').map do |id|
    Books::Genre.new(id)
  end
end

#get_attribute(name) ⇒ Object



30
31
32
33
34
# File 'lib/rakuten_web_service/books/resource.rb', line 30

def get_attribute(name)
  name = name.to_s
  update_params unless @params[name]
  @params[name] 
end