Skip to content

Commit

Permalink
parse methods to extract data from tweet text
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Gorsuch committed Nov 17, 2009
1 parent 1e5c49c commit 9ce74f1
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion models.rb
Expand Up @@ -6,6 +6,7 @@
ActiveRecord::Base.establish_connection dbconfig['production']

class Tweet < ActiveRecord::Base

serialize :source_tweet

def self.fetch
Expand All @@ -28,10 +29,28 @@ def self.fetch

end

def hashtags
def parse_hashtags
text.split(" ").reject do |item|
item[0].chr != '#'
end
end

def parse_minutes
match_data = /.*(\d+) minute?/.match(self.text)
if match_data
match_data[1].to_i + self.parse_hours * 60
else
self.parse_hours * 60
end
end

def parse_hours
match_data = /.*(\d+) hour?/.match(self.text)
if match_data
match_data[1].to_i
else
0
end
end

end

0 comments on commit 9ce74f1

Please sign in to comment.