Module: Torznab::Client::Caps::Mappers::CategoryMapper

Extended by:
CategoryOrSubcategoryMapper
Defined in:
lib/torznab/client/caps/mappers/category_mapper.rb

Overview

Category mapping

Class Method Summary collapse

Class Method Details

.map(xml_element) ⇒ Torznab::Client::Caps::Searching

Map the data from a Nokogiri::XML::Element to a Category object corresponding of a category node of the caps xml

Parameters:

  • xml_element (Nokogiri::XML::Element)

    data from a category node to map

Returns:

  • (Torznab::Client::Caps::Searching)

    Mapped Category instance

Raises:


21
22
23
24
25
26
27
28
29
30
31
# File 'lib/torznab/client/caps/mappers/category_mapper.rb', line 21

def map(xml_element)
  unless xml_element.is_a? Nokogiri::XML::Element
    raise Torznab::Client::Errors::XmlError, 'Provided object is not a Nokogiri::XML::Element'
  end

  category = Category.new
  category.id = map_id xml_element
  category.name = map_name xml_element
  category.subcategories = map_subcategories xml_element
  category
end