Class: TorQML::DataSources::LinearDataSource_rb

Inherits:
DataSource_rb show all
Includes:
QML::Access
Defined in:
lib/torqml/datasources/lineardatasource.rb

Overview

Data source class to provide simple linear data. This class is useful when testing some models without preparing time-series data files.

Instance Method Summary collapse

Methods inherited from DataSource_rb

#currentFrame

Instance Method Details

#dataSizeInteger

Returns the size of data.

Returns:

  • (Integer)

    the size of data



16
# File 'lib/torqml/datasources/lineardatasource.rb', line 16

property(:dataSize) { 0 }

#dataStepFloat

Returns the value step against index.

Returns:

  • (Float)

    the value step against index



18
# File 'lib/torqml/datasources/lineardatasource.rb', line 18

property(:dataStep) { 0 }

#prepare_dataObject

Prepare data to provide.



21
22
23
24
25
# File 'lib/torqml/datasources/lineardatasource.rb', line 21

def prepare_data
  @data = Array.new(self.dataSize) do |i|
    i * self.dataStep
  end
end

#rowsInteger

Returns the number of rows.

Returns:

  • (Integer)

    the number of rows



39
40
41
# File 'lib/torqml/datasources/lineardatasource.rb', line 39

def rows
  @data.length
end

#value_at(index) ⇒ Float

Returns the current frame value. Return value is not dependent on index argument.

Parameters:

  • index (Integer)

    index

Returns:

  • (Float)

    the current frame value



32
33
34
# File 'lib/torqml/datasources/lineardatasource.rb', line 32

def value_at(index)
  @data[currentFrame.to_i - 1]
end