Class: Douban::RecommendationComment
- Inherits:
-
Object
- Object
- Douban::RecommendationComment
- Includes:
- Equal
- Defined in:
- lib/douban/recommendation_comment.rb
Class Method Summary collapse
Instance Method Summary collapse
- #comment_id ⇒ Object
-
#initialize(entry = "") ⇒ RecommendationComment
constructor
A new instance of RecommendationComment.
- #recommendation_id ⇒ Object
Methods included from Equal
Constructor Details
#initialize(entry = "") ⇒ RecommendationComment
18 19 20 21 22 23 24 25 |
# File 'lib/douban/recommendation_comment.rb', line 18 def initialize(entry="") doc = entry.kind_of?(REXML::Element) ? entry : REXML::Document.new(entry) @id = REXML::XPath.first(doc, ".//id/text()").to_s @author = REXML::XPath.first(doc, ".//author") @author = Author.new(@author.to_s) if @author @published = REXML::XPath.first(doc, ".//published/text()").to_s @content = REXML::XPath.first(doc, ".//content/text()").to_s end |
Class Method Details
.attr_names ⇒ Object
9 10 11 |
# File 'lib/douban/recommendation_comment.rb', line 9 def attr_names @@attr_names ||= %w{id author published content}.map {|x| x.to_sym} end |
Instance Method Details
#comment_id ⇒ Object
31 32 33 |
# File 'lib/douban/recommendation_comment.rb', line 31 def comment_id /\/(\d+)$/.match(@id)[1].to_i rescue nil end |
#recommendation_id ⇒ Object
27 28 29 |
# File 'lib/douban/recommendation_comment.rb', line 27 def recommendation_id /recommendation\/(\d+)\/comment/.match(@id)[1].to_i rescue nil end |