Class: Charty::VectorAdapters::VectorAdapter
- Inherits:
-
BaseAdapter
- Object
- BaseAdapter
- Charty::VectorAdapters::VectorAdapter
- Extended by:
- Forwardable
- Includes:
- IndexSupport, NameSupport, Enumerable
- Defined in:
- lib/charty/vector_adapters/vector_adapter.rb
Instance Attribute Summary
Attributes included from IndexSupport
Attributes included from NameSupport
Attributes inherited from BaseAdapter
Class Method Summary collapse
Instance Method Summary collapse
- #compare_data_equality(other) ⇒ Object
-
#initialize(data, index: nil) ⇒ VectorAdapter
constructor
A new instance of VectorAdapter.
Methods included from IndexSupport
Methods inherited from BaseAdapter
#==, adapter_name, #inverse_log_scale, #log_scale, #mean, #percentile, #stdev, #values_at, #where_in_array
Constructor Details
#initialize(data, index: nil) ⇒ VectorAdapter
Returns a new instance of VectorAdapter.
13 14 15 16 17 |
# File 'lib/charty/vector_adapters/vector_adapter.rb', line 13 def initialize(data, index: nil) data = check_data(data) @data = reduce_nested_vector(data) self.index = index || RangeIndex.new(0 ... length) end |
Class Method Details
.supported?(data) ⇒ Boolean
9 10 11 |
# File 'lib/charty/vector_adapters/vector_adapter.rb', line 9 def self.supported?(data) data.is_a?(Vector) end |
Instance Method Details
#compare_data_equality(other) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/charty/vector_adapters/vector_adapter.rb', line 40 def compare_data_equality(other) if other.is_a?(self.class) other = reduce_nested_vector(other.data).adapter end if other.is_a?(self.class) @data.adapter.data == other.data elsif @data.adapter.respond_to?(:compare_data_equality) @data.adapter.compare_data_equality(other) elsif other.respond_to?(:compare_data_equality) other.compare_data_equality(@data.adapter) else @data.adapter.to_a == other.to_a end end |