Class: Churn::ChurnOptions
- Inherits:
-
Object
- Object
- Churn::ChurnOptions
- 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- DEFAULT_START_TIME =
'3 months ago'
Instance Attribute Summary collapse
-
#data_directory ⇒ Object
Returns the value of attribute data_directory.
-
#file_extension ⇒ Object
Returns the value of attribute file_extension.
-
#file_prefix ⇒ Object
Returns the value of attribute file_prefix.
-
#history ⇒ Object
Returns the value of attribute history.
-
#ignores ⇒ Object
Returns the value of attribute ignores.
-
#minimum_churn_count ⇒ Object
Returns the value of attribute minimum_churn_count.
-
#name ⇒ Object
Returns the value of attribute name.
-
#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 19 20 21 22 |
# File 'lib/churn/options.rb', line 13 def initialize() @data_directory = DEFAULT_CHURN_DIRECTORY @minimum_churn_count = DEFAULT_MINIMUM_CHURN_COUNT @ignores = '/dev/null' @start_date = DEFAULT_START_TIME @history = nil @name = nil @file_extension = nil @file_prefix = nil 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 |
#file_extension ⇒ Object
Returns the value of attribute file_extension.
11 12 13 |
# File 'lib/churn/options.rb', line 11 def file_extension @file_extension end |
#file_prefix ⇒ Object
Returns the value of attribute file_prefix.
11 12 13 |
# File 'lib/churn/options.rb', line 11 def file_prefix @file_prefix end |
#history ⇒ Object
Returns the value of attribute history.
11 12 13 |
# File 'lib/churn/options.rb', line 11 def history @history end |
#ignores ⇒ Object
Returns the value of attribute ignores.
11 12 13 |
# File 'lib/churn/options.rb', line 11 def ignores @ignores 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 |
#name ⇒ Object
Returns the value of attribute name.
11 12 13 |
# File 'lib/churn/options.rb', line 11 def name @name 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
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/churn/options.rb', line 24 def ( = {}) @data_directory = .fetch(:data_directory){ @data_directory } unless [:data_directory]=='' @file_extension = .fetch(:file_extension){ @file_extension } unless [:file_extension]=='' @file_prefix = .fetch(:file_prefix){ @file_prefix } unless [:file_prefix]=='' @minimum_churn_count = .fetch(:minimum_churn_count){ @minimum_churn_count }.to_i @ignores = (.fetch(:ignore_files){ [:ignores] || @ignores }).to_s.split(',').map(&:strip) @ignores << '/dev/null' unless @ignores.include?('/dev/null') @start_date = [:start_date] if ![:start_date].nil? && [:start_date]!='' @history = [:history] if ![:history].nil? && [:history]!='' if @history=='true' @history = DEFAULT_START_TIME end self end |