Module: Moon::NData

Included in:
DataMatrix, Table
Defined in:
lib/moon/packages/data_bags/n_data.rb

Overview

Abstraction for classes that have an Array of 1 type for their main data.

Instance Method Summary collapse

Instance Method Details

#write_data(data_p) ⇒ Object

write_data is a variation of change_data, it validates the size of the data set and then replaces the current data with the given


9
10
11
12
13
14
15
16
# File 'lib/moon/packages/data_bags/n_data.rb', line 9

def write_data(data_p)
  if data_p.size > @size
    raise Moon::OverflowError, 'given dataset is larger than internal'
  elsif data_p.size < @size
    raise Moon::UnderflowError, 'given dataset is smaller than internal'
  end
  @data.replace(data_p)
end