Class: Maidcafe::ResultItem

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

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ ResultItem

Returns a new instance of ResultItem.



52
53
54
# File 'lib/ruby-maidcafe.rb', line 52

def initialize(xml)
  read xml
end

Instance Method Details

#attr_to_tagObject



62
63
64
# File 'lib/ruby-maidcafe.rb', line 62

def attr_to_tag
  {}
end

#element_text(xml, tag) ⇒ Object



66
67
68
# File 'lib/ruby-maidcafe.rb', line 66

def element_text(xml, tag)
  (tag = xml.elements[tag]) ? tag.text : nil
end

#read(xml) ⇒ Object



56
57
58
59
60
# File 'lib/ruby-maidcafe.rb', line 56

def read(xml)
  attr_to_tag.each do |attr, tag|
    send "#{attr}=", element_text(xml, tag)
  end
end

#to_sObject



70
71
72
# File 'lib/ruby-maidcafe.rb', line 70

def to_s
  "ID: #{id}\n名前: #{name}"
end