Class: Douban::MiniblogComments
- Inherits:
-
Struct
- Object
- Struct
- Douban::MiniblogComments
- Defined in:
- lib/douban/miniblog_comments.rb
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#comments ⇒ Object
Returns the value of attribute comments.
-
#page_info ⇒ Object
Returns the value of attribute page_info.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(*args) ⇒ MiniblogComments
constructor
A new instance of MiniblogComments.
Constructor Details
#initialize(*args) ⇒ MiniblogComments
Returns a new instance of MiniblogComments.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/douban/miniblog_comments.rb', line 9 def initialize(*args) if args.size != 1 super(*args) return end atom = args[0] doc = case atom when REXML::Document then atom.root when REXML::Element then atom else REXML::Document.new(atom).root end self.title = REXML::XPath.first(doc, "./title/text()").to_s rescue nil = REXML::XPath.first(doc, "./author") self. = Author.new() if self.comments = [] REXML::XPath.each(doc, "./entry") do |entry| self.comments << MiniblogComment.new(entry) end self.page_info = PageInfo.new(doc) end |
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author
8 9 10 |
# File 'lib/douban/miniblog_comments.rb', line 8 def @author end |
#comments ⇒ Object
Returns the value of attribute comments
8 9 10 |
# File 'lib/douban/miniblog_comments.rb', line 8 def comments @comments end |
#page_info ⇒ Object
Returns the value of attribute page_info
8 9 10 |
# File 'lib/douban/miniblog_comments.rb', line 8 def page_info @page_info end |
#title ⇒ Object
Returns the value of attribute title
8 9 10 |
# File 'lib/douban/miniblog_comments.rb', line 8 def title @title end |