Class: Retrobot::Config

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

Constant Summary collapse

KEYS =
%i(
  tweets_csv
  consumer_key
  consumer_secret
  access_token
  access_secret
  retro_days
  retweet
  debug
  dryrun
  loop_interval
  retry_interval
  retry_count
  add_in_reply_to_url
  suppress_pattern
  remove_hashtag
)
DEFAULTS =
{
  tweets_csv: './tweets/tweets.csv',
  retro_days: 365,
  retweet: false,
  debug: false,
  dryrun: false,
  loop_interval: 3,
  retry_interval: 3,
  retry_count: 5,
  add_in_reply_to_url: false,
  suppress_pattern: nil,
  remove_hashtag: false,
}

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Config

Returns a new instance of Config.



39
40
41
# File 'lib/retrobot/config.rb', line 39

def initialize(options={})
  @options = DEFAULTS.merge(options.symbolize_keys)
end

Instance Method Details

#load_yaml_file!(path) ⇒ Object



63
64
65
# File 'lib/retrobot/config.rb', line 63

def load_yaml_file!(path)
  @options.merge! Psych.load_file(path.to_s).symbolize_keys
end

#loop_intervalObject



59
# File 'lib/retrobot/config.rb', line 59

def loop_interval;  @options[:loop_interval].to_i; end

#merge!(hash) ⇒ Object



43
44
45
# File 'lib/retrobot/config.rb', line 43

def merge!(hash)
  @options.merge!(hash)
end

#retro_daysObject



51
52
53
# File 'lib/retrobot/config.rb', line 51

def retro_days
  @options[:retro_days].to_i.days
end

#retry_countObject



61
# File 'lib/retrobot/config.rb', line 61

def retry_count;    @options[:retry_count].to_i; end

#retry_intervalObject



60
# File 'lib/retrobot/config.rb', line 60

def retry_interval; @options[:retry_interval].to_i; end

#tweets_csvObject



55
56
57
# File 'lib/retrobot/config.rb', line 55

def tweets_csv
  Pathname.new(@options[:tweets_csv])
end