Class: ApiBucket::Service
- Inherits:
-
Object
- Object
- ApiBucket::Service
- Defined in:
- lib/api_bucket.rb
Overview
Service
Constant Summary collapse
- SERVICE_AMAZON =
0
- SERVICE_YAHOOAUCTION =
2
- SERVICE_RAKUTEN =
3
- SERVICE_ITUNES =
4
- SERVICE_FRUSTRATION =
5
- @@services =
{ amazon: SERVICE_AMAZON, yahooauction: SERVICE_YAHOOAUCTION, rakuten: SERVICE_RAKUTEN, itunes: SERVICE_ITUNES, frustration: SERVICE_FRUSTRATION, }
Class Method Summary collapse
Class Method Details
.code(name) ⇒ Object
76 77 78 79 80 |
# File 'lib/api_bucket.rb', line 76 def self.code(name) raise ArgumentError, 'no api code' unless @@services.key?(:"#{name}") @@services[:"#{name}"] end |
.instance(type) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/api_bucket.rb', line 57 def self.instance(type) case type when :amazon service = ApiBucket::Amazon::Client.new when :yahooauction service = ApiBucket::Yahooauction::Client.new when :rakuten service = ApiBucket::Rakuten::Client.new when :itunes service = ApiBucket::Itunes::Client.new when :frustration else raise ArgumentError, 'no api module' end service end |
.name(code) ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/api_bucket.rb', line 82 def self.name(code) @@services.each do |k, v| return k if v == code end raise ArgumentError, 'no api code' end |