Class: Retrobot::Tweet

Inherits:
Object
  • Object
show all
Defined in:
lib/retrobot/tweet.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#expanded_urlsObject

Returns the value of attribute expanded_urls.



5
6
7
# File 'lib/retrobot/tweet.rb', line 5

def expanded_urls
  @expanded_urls
end

#in_reply_to_status_idObject

Returns the value of attribute in_reply_to_status_id.



5
6
7
# File 'lib/retrobot/tweet.rb', line 5

def in_reply_to_status_id
  @in_reply_to_status_id
end

#in_reply_to_user_idObject

Returns the value of attribute in_reply_to_user_id.



5
6
7
# File 'lib/retrobot/tweet.rb', line 5

def in_reply_to_user_id
  @in_reply_to_user_id
end

#retweeted_status_idObject

Returns the value of attribute retweeted_status_id.



5
6
7
# File 'lib/retrobot/tweet.rb', line 5

def retweeted_status_id
  @retweeted_status_id
end

#retweeted_status_timestampObject

Returns the value of attribute retweeted_status_timestamp.



5
6
7
# File 'lib/retrobot/tweet.rb', line 5

def retweeted_status_timestamp
  @retweeted_status_timestamp
end

#retweeted_status_user_idObject

Returns the value of attribute retweeted_status_user_id.



5
6
7
# File 'lib/retrobot/tweet.rb', line 5

def retweeted_status_user_id
  @retweeted_status_user_id
end

#sourceObject

Returns the value of attribute source.



5
6
7
# File 'lib/retrobot/tweet.rb', line 5

def source
  @source
end

#textObject

Returns the value of attribute text.



5
6
7
# File 'lib/retrobot/tweet.rb', line 5

def text
  @text
end

#timestampObject

Returns the value of attribute timestamp.



5
6
7
# File 'lib/retrobot/tweet.rb', line 5

def timestamp
  @timestamp
end

#tweet_idObject

Returns the value of attribute tweet_id.



5
6
7
# File 'lib/retrobot/tweet.rb', line 5

def tweet_id
  @tweet_id
end

Class Method Details

.parse_line(cols) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/retrobot/tweet.rb', line 8

def self.parse_line(cols)
  t = self.new
  t.tweet_id = str_to_int_or_nil(cols[0])
  t.in_reply_to_status_id = str_to_int_or_nil(cols[1])
  t.in_reply_to_user_id = str_to_int_or_nil(cols[2])
  t.timestamp = cols[3]
  t.source = cols[4]
  t.text = cols[5]
  t.retweeted_status_id = str_to_int_or_nil(cols[6])
  t.retweeted_status_user_id = str_to_int_or_nil(cols[7])
  t.retweeted_status_timestamp = str_to_time_or_nil(cols[8])
  t.expanded_urls = cols[9..-1]
  t
end

.str_to_int_or_nil(str) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/retrobot/tweet.rb', line 23

def self.str_to_int_or_nil(str)
  if str.nil? || str.empty?
    nil
  else
    str.to_i
  end
end

.str_to_time_or_nil(str) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/retrobot/tweet.rb', line 31

def self.str_to_time_or_nil(str)
  if str.nil? || str.empty?
    nil
  else
    Time.parse(str).localtime
  end
end