Module: LiveJournal::Sync::CommentsXML

Defined in:
lib/livejournal/comments-xml.rb

Defined Under Namespace

Classes: Base, WithExpat, WithREXML

Constant Summary collapse

Parser =
WithREXML

Class Method Summary collapse

Class Method Details

.load_comment_from_attrs(comment, attrs) ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/livejournal/comments-xml.rb', line 47

def self.load_comment_from_attrs(comment, attrs)
  comment.commentid = attrs['id'].to_i
  comment.posterid = CommentsXML::optional_int_string attrs['posterid']
  comment.itemid   = CommentsXML::optional_int_string attrs['jitemid']
  comment.parentid = CommentsXML::optional_int_string attrs['parentid']
  statestr = attrs['state']
  comment.state    = LiveJournal::Comment::state_from_string(statestr) if statestr
end

.optional_int_string(x) ⇒ Object



42
43
44
45
# File 'lib/livejournal/comments-xml.rb', line 42

def self.optional_int_string(x)
  return nil unless x
  x.to_i
end