Sha256: acd2b1ff20c31a51d8259fcbb55d6ecb11591e920d3b076a530eef4ae76f268e

Contents?: true

Size: 985 Bytes

Versions: 1

Compression:

Stored size: 985 Bytes

Contents

module RakutenWebService
  module Ichiba
    class Genre < Resource
      @@repository = {}

      class << self
        def parse_response(response)
          [Genre.new(response['current'])]
        end

        def new(params)
          case params
          when Integer, String
            Genre[params.to_s] || search(:genre_id => params.to_s).first
          when Hash
            super
          end
        end

        def root
          self.new(0)
        end

        def [](id)
          @@repository[id.to_s]
        end

        def []=(id, genre)
          @@repository[id.to_s] = genre
        end
      end

      endpoint 'https://app.rakuten.co.jp/services/api/IchibaGenre/Search/20120723'
      attribute :genreId, :genreName, :genreLevel

      def initialize(params)
        super
        Genre[self.id.to_s] = self
      end

      def ranking(options={})
        RakutenWebService::Ichiba::RankingItem.search(:genre_id => self.id)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rakuten_web_service-0.0.1 lib/rakuten_web_service/ichiba/genre.rb