-
Notifications
You must be signed in to change notification settings - Fork 0
/
tweet.rb
40 lines (31 loc) · 878 Bytes
/
tweet.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class Tweet
def initialize(data)
@data = data
end
def user_link
"http://twitter.com/#{username}"
end
# Makes links clickable, etc.
def filtered_text
text
#filter_lol(filter_urls(text))
end
def jasonize
@data.to_json
end
private
# So we can call tweet.text instead of tweet['text']
def method_missing(name)
@data[name.to_s]
end
#def filter_lol(text)
# # Note that we're using a list of characters rather than just \b to avoid
# # replacing LOL inside a URL.
# text.gsub(/^(.*[\s\.\,\;])?(lol)(\b)/i, '\1<span class="lol">\2</span>\3')
#end
#def filter_urls(text)
# # The regex could probably still be improved, but this seems to do the
# # trick for most cases.
# text.gsub(/(https?:\/\/\w+(\.\w+)+(\/[\w\+\-\,\%]+)*(\?[\w\[\]]+(=\w*)?(&\w+(=\w*)?)*)?(#\w+)?)/i, '<a href="\1">\1</a>')
#end
end