class TweetWatch::Config
Attributes
accounts[RW]
count[RW]
error_message[R]
path[RW]
tweeters[RW]
Public Class Methods
new()
click to toggle source
# File lib/tweet_watch/config.rb, line 7 def initialize @accounts = [] @tweeters = [] @count = 50 @error_message = "" end
Public Instance Methods
get_account(screen_name = nil)
click to toggle source
# File lib/tweet_watch/config.rb, line 50 def get_account(screen_name = nil) account = @accounts.first unless screen_name.nil? res = @accounts.select { |u| u.screen_name.strip() == screen_name.strip() } account = res.first if res.size > 0 end return account end
has_tweeter?(tweeter)
click to toggle source
# File lib/tweet_watch/config.rb, line 39 def has_tweeter?(tweeter) res = @tweeters.find{|t| t.downcase.strip == tweeter.downcase.strip } res != nil end
load_from_path(path)
click to toggle source
# File lib/tweet_watch/config.rb, line 14 def load_from_path(path) unless File.exist?(path) raise ArgumentError.new("The provided config file could not be located: #{path}") end @path = path c = YAML.load_file(@path) unless c["accounts"].nil? c["accounts"].each do |f| self.accounts << Account.new(f["screen_name"], f["consumer_key"], f["consumer_secret"], f["access_token"], f["access_token_secret"]) end end unless c["tweeters"].nil? c["tweeters"].each do |t| self.tweeters << t unless has_tweeter?(t) end end self end
valid?()
click to toggle source
# File lib/tweet_watch/config.rb, line 44 def valid? @error_message = "" @error_message += "There should be at least one account" if accounts.size ==0 @error_message.strip().length == 0 end