Class: LiveJournal::Sync::CommentsXML::WithExpat::Parser
- Inherits:
-
XMLParser
- Object
- XMLParser
- LiveJournal::Sync::CommentsXML::WithExpat::Parser
- Defined in:
- lib/livejournal/comments-xml.rb
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
Returns the value of attribute comments.
-
#maxid ⇒ Object
readonly
Returns the value of attribute maxid.
-
#usermap ⇒ Object
readonly
Returns the value of attribute usermap.
Instance Method Summary collapse
- #character(data) ⇒ Object
- #endElement(name) ⇒ Object
-
#initialize ⇒ Parser
constructor
A new instance of Parser.
- #startElement(name, attrs) ⇒ Object
Constructor Details
#initialize ⇒ Parser
Returns a new instance of Parser.
95 96 97 98 99 100 101 102 |
# File 'lib/livejournal/comments-xml.rb', line 95 def initialize super @maxid = nil @cur_comment = nil @comments = {} @usermap = {} @content = nil end |
Instance Attribute Details
#comments ⇒ Object (readonly)
Returns the value of attribute comments.
94 95 96 |
# File 'lib/livejournal/comments-xml.rb', line 94 def comments @comments end |
#maxid ⇒ Object (readonly)
Returns the value of attribute maxid.
94 95 96 |
# File 'lib/livejournal/comments-xml.rb', line 94 def maxid @maxid end |
#usermap ⇒ Object (readonly)
Returns the value of attribute usermap.
94 95 96 |
# File 'lib/livejournal/comments-xml.rb', line 94 def usermap @usermap end |
Instance Method Details
#character(data) ⇒ Object
124 125 126 |
# File 'lib/livejournal/comments-xml.rb', line 124 def character(data) @content << data if @content end |
#endElement(name) ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/livejournal/comments-xml.rb', line 127 def endElement(name) return unless @content case name when 'maxid' @maxid = @content.to_i when 'date' @cur_comment.time = Time::xmlschema(@content) when 'subject' @cur_comment.subject = @content when 'body' @cur_comment.body = @content end @content = nil end |
#startElement(name, attrs) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/livejournal/comments-xml.rb', line 103 def startElement(name, attrs) case name when 'maxid' @content = '' when 'comment' id = attrs['id'].to_i @cur_comment = @comments[id] || Comment.new @comments[id] = @cur_comment CommentsXML::load_comment_from_attrs(@cur_comment, attrs) when 'usermap' id = attrs['id'].to_i user = attrs['user'] @usermap[id] = user when 'date' @content = '' when 'subject' @content = '' when 'body' @content = '' end end |