Class: Churn::ChurnOptions

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/churn_options.rb

Overview

responsible for storing the churn configuration

Constant Summary collapse

DEFAULT_CHURN_DIRECTORY =
"tmp/churn"
DEFAULT_MINIMUM_CHURN_COUNT =
5

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeChurnOptions

Returns a new instance of ChurnOptions.



13
14
15
16
17
18
# File 'lib/churn_options.rb', line 13

def initialize()
  @data_directory      = DEFAULT_CHURN_DIRECTORY
  @minimum_churn_count = DEFAULT_MINIMUM_CHURN_COUNT
  @ignore_files        = ['/dev/null']
  @start_date          = '3 months ago'
end

Instance Attribute Details

#data_directoryObject

Returns the value of attribute data_directory.



11
12
13
# File 'lib/churn_options.rb', line 11

def data_directory
  @data_directory
end

#ignore_filesObject

Returns the value of attribute ignore_files.



11
12
13
# File 'lib/churn_options.rb', line 11

def ignore_files
  @ignore_files
end

#minimum_churn_countObject

Returns the value of attribute minimum_churn_count.



11
12
13
# File 'lib/churn_options.rb', line 11

def minimum_churn_count
  @minimum_churn_count
end

#start_dateObject

Returns the value of attribute start_date.



11
12
13
# File 'lib/churn_options.rb', line 11

def start_date
  @start_date
end

Instance Method Details

#set_options(options = {}) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/churn_options.rb', line 20

def set_options(options = {})
  @data_directory      = options.fetch(:data_directory){ @data_directory } unless options[:data_directory]==''
  @minimum_churn_count = options.fetch(:minimum_churn_count){ @minimum_churn_count }.to_i
  @ignore_files        = (options.fetch(:ignore_files){ @ignore_files }).to_s.split(',').map(&:strip)
  @ignore_files << '/dev/null' unless @ignore_files.include?('/dev/null')
  @start_date          = options[:start_date] if options[:start_date].nil? || options[:start_date]!=''
  self
end