Class: Spout::Models::OutlierResult
- Inherits:
-
Object
- Object
- Spout::Models::OutlierResult
- Defined in:
- lib/spout/models/outlier_result.rb
Instance Attribute Summary collapse
-
#csv_files ⇒ Object
readonly
Returns the value of attribute csv_files.
-
#display_name ⇒ Object
readonly
Returns the value of attribute display_name.
-
#major_outliers ⇒ Object
readonly
Returns the value of attribute major_outliers.
-
#median ⇒ Object
readonly
Returns the value of attribute median.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#minor_outliers ⇒ Object
readonly
Returns the value of attribute minor_outliers.
-
#outliers ⇒ Object
readonly
Returns the value of attribute outliers.
-
#units ⇒ Object
readonly
Returns the value of attribute units.
-
#variable_type ⇒ Object
readonly
Returns the value of attribute variable_type.
-
#weight ⇒ Object
readonly
Returns the value of attribute weight.
Instance Method Summary collapse
- #calculate_outliers! ⇒ Object
-
#initialize(subjects, method, csv_files) ⇒ OutlierResult
constructor
A new instance of OutlierResult.
Constructor Details
#initialize(subjects, method, csv_files) ⇒ OutlierResult
Returns a new instance of OutlierResult.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/spout/models/outlier_result.rb', line 13 def initialize(subjects, method, csv_files) @values = subjects.collect(&method.to_sym) @csv_files = csv_files @method = method calculate_outliers! @weight = \ if @major_outliers.count > 0 0 elsif @minor_outliers.count > 0 1 else 2 end variable = Spout::Helpers::JsonLoader::get_variable(method) @units = (variable.is_a?(Hash) ? variable["units"] : nil) @display_name = (variable.is_a?(Hash) ? variable["display_name"] : nil) @variable_type = (variable.is_a?(Hash) ? variable["type"] : nil) @median = @values.median end |
Instance Attribute Details
#csv_files ⇒ Object (readonly)
Returns the value of attribute csv_files.
9 10 11 |
# File 'lib/spout/models/outlier_result.rb', line 9 def csv_files @csv_files end |
#display_name ⇒ Object (readonly)
Returns the value of attribute display_name.
9 10 11 |
# File 'lib/spout/models/outlier_result.rb', line 9 def display_name @display_name end |
#major_outliers ⇒ Object (readonly)
Returns the value of attribute major_outliers.
9 10 11 |
# File 'lib/spout/models/outlier_result.rb', line 9 def major_outliers @major_outliers end |
#median ⇒ Object (readonly)
Returns the value of attribute median.
9 10 11 |
# File 'lib/spout/models/outlier_result.rb', line 9 def median @median end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
9 10 11 |
# File 'lib/spout/models/outlier_result.rb', line 9 def method @method end |
#minor_outliers ⇒ Object (readonly)
Returns the value of attribute minor_outliers.
9 10 11 |
# File 'lib/spout/models/outlier_result.rb', line 9 def minor_outliers @minor_outliers end |
#outliers ⇒ Object (readonly)
Returns the value of attribute outliers.
9 10 11 |
# File 'lib/spout/models/outlier_result.rb', line 9 def outliers @outliers end |
#units ⇒ Object (readonly)
Returns the value of attribute units.
9 10 11 |
# File 'lib/spout/models/outlier_result.rb', line 9 def units @units end |
#variable_type ⇒ Object (readonly)
Returns the value of attribute variable_type.
9 10 11 |
# File 'lib/spout/models/outlier_result.rb', line 9 def variable_type @variable_type end |
#weight ⇒ Object (readonly)
Returns the value of attribute weight.
9 10 11 |
# File 'lib/spout/models/outlier_result.rb', line 9 def weight @weight end |
Instance Method Details
#calculate_outliers! ⇒ Object
33 34 35 36 37 |
# File 'lib/spout/models/outlier_result.rb', line 33 def calculate_outliers! @major_outliers = @values.major_outliers.uniq @minor_outliers = @values.minor_outliers.uniq @outliers = @values.outliers.uniq end |