Class TwitterTweet
In: app/models/twitter_tweet.rb
Parent: ActiveRecord::Base

Methods

Constants

TYPE_CHARACTER = 'character_id'
TYPE_WORD = 'word_id'
SOURCE_JLPT = 'jlpt'
SOURCE_LEARNING = 'learning'
SOURCE_MOMENT_OF = 'moment_of'

Public Class methods

Find the last tweet that was successfully sent. May return null if none found.

Type is either TYPE_WORD or TYPE_CHARACTER Source is either SOURCE_MOMENT_OF or SOURCE_LEARNING

[Source]

    # File app/models/twitter_tweet.rb, line 34
34:   def self.last_tweet(tweet_type = TYPE_WORD, tweet_source = SOURCE_MOMENT_OF)
35:     return TwitterTweet.find(
36:       :first, 
37:       :conditions => ["is_sent = ? and #{tweet_type} is not null and source = ?", true, tweet_source],
38:       :order => "created_at DESC", 
39:       :limit => 1
40:     )
41:   end

Find all the tweets since a specified date and time. Defaults to finding to only those that were successfully send. May return an empty array if none found

Type is either TYPE_WORD or TYPE_CHARACTER Source is either SOURCE_MOMENT_OF or SOURCE_LEARNING

[Source]

    # File app/models/twitter_tweet.rb, line 48
48:   def self.last_tweets(since, is_successfully_sent = true, tweet_type = TYPE_WORD, tweet_source = SOURCE_MOMENT_OF)
49:     return TwitterTweet.find(
50:       :all, 
51:       :conditions => ["created_at >= ? and is_sent = ? and #{tweet_type} is not null and source = ?", since, is_successfully_sent, tweet_source]
52:     )
53:   end

Enumeration of twitter sources.

[Source]

    # File app/models/twitter_tweet.rb, line 22
22:   def self.twitter_sources
23:     twitter_sources = Array.new
24:     twitter_sources << SOURCE_JLPT
25:     twitter_sources << SOURCE_LEARNING
26:     twitter_sources << SOURCE_MOMENT_OF
27:     twitter_sources
28:   end

Enumeration of twitter types

[Source]

    # File app/models/twitter_tweet.rb, line 14
14:   def self.twitter_types
15:     twitter_types = Array.new
16:     twitter_types << TYPE_CHARACTER
17:     twitter_types << TYPE_WORD
18:     twitter_types
19:   end

[Validate]