Class: Douban::MiniblogComment
- Inherits:
-
Object
- Object
- Douban::MiniblogComment
- Includes:
- Equal
- Defined in:
- lib/douban/miniblog_comment.rb
Class Method Summary collapse
Instance Method Summary collapse
- #comment_id ⇒ Object
-
#initialize(atom) ⇒ MiniblogComment
constructor
A new instance of MiniblogComment.
- #miniblog_id ⇒ Object
Methods included from Equal
Constructor Details
#initialize(atom) ⇒ MiniblogComment
Returns a new instance of MiniblogComment.
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/douban/miniblog_comment.rb', line 22 def initialize(atom) doc = case atom when REXML::Document then atom.root when REXML::Element then atom else REXML::Document.new(atom).root end @id = REXML::XPath.first(doc, "./id/text()").to_s rescue nil = REXML::XPath.first(doc, "./author") @author = Author.new() if @published = REXML::XPath.first(doc, "./published/text()").to_s rescue nil @content = REXML::XPath.first(doc, "./content/text()").to_s rescue nil end |
Class Method Details
.attr_names ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/douban/miniblog_comment.rb', line 10 def attr_names [ :id, :author, :published, :content ] end |
Instance Method Details
#comment_id ⇒ Object
38 39 40 |
# File 'lib/douban/miniblog_comment.rb', line 38 def comment_id /\/(\d+)$/.match(@id)[1].to_i rescue nil end |
#miniblog_id ⇒ Object
35 36 37 |
# File 'lib/douban/miniblog_comment.rb', line 35 def miniblog_id /miniblog\/(\d+)\/comment/.match(@id)[1].to_i rescue nil end |