Class: Discogs::GenericList
- Defined in:
- lib/wrapper/resources/generic_list.rb
Overview
Represents a generic list of items in the Discogs API.
Instance Method Summary collapse
-
#[](index) ⇒ Object
Provides post-build access to the list.
-
#build! ⇒ Object
Overload build method to provide custom process for converting contents into something useful.
Methods inherited from Resource
#build_with_resp!, #initialize, #original_content
Methods included from ResourceMappings
Constructor Details
This class inherits a constructor from Discogs::Resource
Instance Method Details
#[](index) ⇒ Object
Provides post-build access to the list.
23 24 25 26 27 |
# File 'lib/wrapper/resources/generic_list.rb', line 23 def [](index) if @items.is_a?(Array) @items[index] end end |
#build! ⇒ Object
Overload build method to provide custom process for converting contents into something useful.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/wrapper/resources/generic_list.rb', line 11 def build! @items = [] document = REXML::Document.new(@content) document.root.each_element do |element| @items << element.text end @items end |