Module: Mogo24r::TimelineParser

Defined in:
lib/mogo24r/timeline_parser.rb

Overview

TimelineParser for mogo2-API response.

Instance Method Summary collapse

Instance Method Details

#parse_status(status) ⇒ Object

Description

parse-method for status-element.

Params

status (REXML::Element-Instance)

Return

=> 12345, …

RelatedMethods

parse_timeline parse_user



50
51
52
53
54
55
56
57
58
59
# File 'lib/mogo24r/timeline_parser.rb', line 50

def parse_status(status)
  result = {
    :text => status.elements['text'].text,
    :id => status.elements['id'].text.to_i,
    :res_count => status.elements['res_count'].text.to_i,
    :created_at => DateTime.parse(status.elements['created_at'].text),
    :user => parse_user(status.elements['user'])
  }
  return result
end

#parse_timeline(text) ⇒ Object

Description

timeline-parser for mogo2-API.

Params

text (mogo2-API response)

Return
=> 12345, …
RelatedMethods

parse_status



75
76
77
78
79
80
# File 'lib/mogo24r/timeline_parser.rb', line 75

def parse_timeline(text)
  doc = REXML::Document.new(text)
  doc.elements.collect('//statuses/status'){|status|
    parse_status(status)
  }
end

#parse_user(user) ⇒ Object

Description

parser-method for user-element.

Params

user (REXML::Element-Instance)

Return

=> 12345, …

RelatedMethods

parse_timeline, parse_status



25
26
27
28
29
30
31
32
33
# File 'lib/mogo24r/timeline_parser.rb', line 25

def parse_user(user)
  result = {
    :id => user.elements['id'].text.to_i,
    :screen_name => user.elements['screen_name'].text,
    :description => user.elements['description'].text,
    :profile_image_url => URI.parse(user.elements['profile_image_url'].text)
  }
  return result
end