Class: Maidcafe::ResultSet

Inherits:
ResultItem show all
Defined in:
lib/ruby-maidcafe.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ResultItem

#element_text, #read, #to_s

Constructor Details

#initialize(type, xml) ⇒ ResultSet

Returns a new instance of ResultSet.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/ruby-maidcafe.rb', line 78

def initialize(type, xml)
  @items = []
  read xml
  xml.elements.each('channel/item') do |item|
    @items.push(
      if item.elements['image']; Moe.new(type, item)
      elsif item.elements['tid']; Prefecture.new(item)
      elsif item.elements['cid']; Category.new(item)
      elsif item.elements['sid']; Shop.new(item)
      elsif item.elements['keytype']; Type.new(item)
      else; raise ArgumentError.new(item.inspect)
      end
    )
  end
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



76
77
78
# File 'lib/ruby-maidcafe.rb', line 76

def description
  @description
end

#generatorObject

Returns the value of attribute generator.



76
77
78
# File 'lib/ruby-maidcafe.rb', line 76

def generator
  @generator
end

#itemsObject

Returns the value of attribute items.



76
77
78
# File 'lib/ruby-maidcafe.rb', line 76

def items
  @items
end

#languageObject

Returns the value of attribute language.



76
77
78
# File 'lib/ruby-maidcafe.rb', line 76

def language
  @language
end

Returns the value of attribute link.



76
77
78
# File 'lib/ruby-maidcafe.rb', line 76

def link
  @link
end

#titleObject

Returns the value of attribute title.



76
77
78
# File 'lib/ruby-maidcafe.rb', line 76

def title
  @title
end

Instance Method Details

#attr_to_tagObject



94
95
96
97
# File 'lib/ruby-maidcafe.rb', line 94

def attr_to_tag
  {:title => 'channel/title', :link => 'channel/link', :description => 'channel/description', 
    :language => 'channel/language', :generator => 'channel/generator'}
end