a2z 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -198,22 +198,26 @@ For example:
198
198
  item.title
199
199
  => "Away From The World (Deluxe Version)"
200
200
 
201
+ item.keys
202
+ => ["artist", "manufacturer", "product_group"]
203
+
204
+ item.composer?
205
+ => false
206
+
207
+ item.artist? # or item.manufacturer? or item.product_group?
208
+ => true
209
+
201
210
  item.artist
202
211
  => "Dave Matthews Band"
203
212
 
204
- item.detail_page_url
205
- => ""http://www.amazon.com/Away-From-World-Deluxe-Version/dp/B008FERRFO..."
206
-
207
213
  item.manufacturer
208
214
  => "RCA"
209
215
 
210
216
  item.product_group
211
217
  => "Music"
212
-
213
- Note that some attributes like `artist` and `manufacturer` are only set
214
- depending upon the type of item. There is currently no way to determine which
215
- attributes have been set on an item object instance. This issue will be
216
- addressed in the next gem release.
218
+
219
+ item.detail_page_url
220
+ => ""http://www.amazon.com/Away-From-World-Deluxe-Version/dp/B008FERRFO..."
217
221
 
218
222
  ### Operation Requests
219
223
 
@@ -242,7 +246,7 @@ For example:
242
246
  => Hash
243
247
 
244
248
  response.operation_request.arguments['Operation']
245
- => "ItemSearch"
249
+ => "ItemLookup"
246
250
 
247
251
  ## Contributing
248
252
 
@@ -7,11 +7,39 @@ module A2z
7
7
 
8
8
  def initialize
9
9
  @links = []
10
+ @attrs = {}
11
+ end
12
+
13
+ def keys
14
+ @attrs.keys
15
+ end
16
+
17
+ def respond_to_missing?(name, include_private = false)
18
+ name.to_s.end_with?('?') || super
19
+ end
20
+
21
+ def method_missing(name, *args, &block)
22
+ method_name = name.to_s
23
+
24
+ if method_name.end_with?('?') # && method_name != 'has_key?'
25
+ has_key?(method_name.sub(/\?$/, ''))
26
+ elsif has_key?(method_name)
27
+ self[method_name]
28
+ else
29
+ super
30
+ end
10
31
  end
11
32
 
12
33
  def []=(key, value)
13
- instance_variable_set("@#{key}".to_sym, value)
14
- self.class.class_eval { attr_reader key.to_sym }
34
+ @attrs[key] = value
35
+ end
36
+
37
+ def [](key)
38
+ @attrs[key]
39
+ end
40
+
41
+ def has_key?(key)
42
+ @attrs.has_key?(key)
15
43
  end
16
44
 
17
45
  def self.from_response(data)
@@ -1,3 +1,3 @@
1
1
  module A2z
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: a2z
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Huggins
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-12-27 00:00:00 -05:00
18
+ date: 2012-12-29 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency