Class: OptionLab::Models::ArrayInputs
- Defined in:
- lib/option_lab/models.rb
Overview
Array inputs model
Instance Attribute Summary collapse
-
#array ⇒ Object
Returns the value of attribute array.
-
#model ⇒ Object
Returns the value of attribute model.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ ArrayInputs
constructor
A new instance of ArrayInputs.
- #validate! ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ ArrayInputs
Returns a new instance of ArrayInputs.
578 579 580 581 582 583 584 585 586 587 588 589 590 |
# File 'lib/option_lab/models.rb', line 578 def initialize(attributes = {}) # Set defaults @model = 'array' super(attributes) # Convert array to Numo::DFloat if @array.is_a?(Array) @array = Numo::DFloat.cast(@array) end validate! end |
Instance Attribute Details
#array ⇒ Object
Returns the value of attribute array.
576 577 578 |
# File 'lib/option_lab/models.rb', line 576 def array @array end |
#model ⇒ Object
Returns the value of attribute model.
576 577 578 |
# File 'lib/option_lab/models.rb', line 576 def model @model end |
Instance Method Details
#validate! ⇒ Object
592 593 594 595 |
# File 'lib/option_lab/models.rb', line 592 def validate! raise ArgumentError, "model must be 'array'" unless model == 'array' raise ArgumentError, 'The array is empty!' if array.empty? end |