Class: DMM::Response::Result
- Inherits:
-
Object
- Object
- DMM::Response::Result
- Defined in:
- lib/ruby-dmm/response.rb
Constant Summary collapse
- RESULT_KEYS =
[ :first_position, :items, :result_count, :total_count, ]
Instance Method Summary collapse
-
#initialize(result) ⇒ Result
constructor
A new instance of Result.
Constructor Details
#initialize(result) ⇒ Result
Returns a new instance of Result.
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ruby-dmm/response.rb', line 28 def initialize(result) RESULT_KEYS.each do |key| case key when :items @items = [result[:items][:item]].flatten.map do |item| DMM::Response::Item.new(item) end if result.key?(:items) @items ||= [] else instance_variable_set("@#{key}", result[key].to_i) end end end |