Class: Churn::ChurnOptions
- Inherits:
-
Object
- Object
- Churn::ChurnOptions
- 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
-
#data_directory ⇒ Object
Returns the value of attribute data_directory.
-
#ignore_files ⇒ Object
Returns the value of attribute ignore_files.
-
#minimum_churn_count ⇒ Object
Returns the value of attribute minimum_churn_count.
-
#start_date ⇒ Object
Returns the value of attribute start_date.
Instance Method Summary collapse
-
#initialize ⇒ ChurnOptions
constructor
A new instance of ChurnOptions.
- #set_options(options = {}) ⇒ Object
Constructor Details
#initialize ⇒ ChurnOptions
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_directory ⇒ Object
Returns the value of attribute data_directory.
11 12 13 |
# File 'lib/churn_options.rb', line 11 def data_directory @data_directory end |
#ignore_files ⇒ Object
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_count ⇒ Object
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_date ⇒ Object
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 ( = {}) @data_directory = .fetch(:data_directory){ @data_directory } unless [:data_directory]=='' @minimum_churn_count = .fetch(:minimum_churn_count){ @minimum_churn_count }.to_i @ignore_files = (.fetch(:ignore_files){ @ignore_files }).to_s.split(',').map(&:strip) @ignore_files << '/dev/null' unless @ignore_files.include?('/dev/null') @start_date = [:start_date] if [:start_date].nil? || [:start_date]!='' self end |