Class: Douban::Tag
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(atom = "") ⇒ Tag
constructor
A new instance of Tag.
Methods included from Equal
Constructor Details
#initialize(atom = "") ⇒ Tag
Returns a new instance of Tag.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/douban/tag.rb', line 21 def initialize(atom="") doc = case atom when REXML::Document then atom.root when REXML::Element then atom when nil then nil else REXML::Document.new(atom).root end unless doc.nil? id=REXML::XPath.first(doc,"./id") @id=id.text if id title=REXML::XPath.first(doc,"./title") @title=title.text if title @count=REXML::XPath.first(doc,"./db:count/text()").to_s.to_i rescue nil end end |
Class Method Details
.attr_names ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/douban/tag.rb', line 9 def attr_names [ :id, :count, :title ] end |