Class: Quandl::Cassandra::Models::Column::Read::Row

Inherits:
Quandl::Cassandra::Models::Column::Read show all
Defined in:
lib/quandl/cassandra/models/column/read/row.rb

Instance Method Summary collapse

Methods inherited from Quandl::Cassandra::Models::Column::Read

#column_collapses, #column_ids, #column_ids=, #count?, perform

Instance Method Details

#performObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/quandl/cassandra/models/column/read/row.rb', line 3

def perform
  return unless attributes[:row].present?
  # ensure integer
  row = attributes[:row]
  # negative value needs inversion
  if row < 0
    attributes[:order]   = :asc
    attributes[:offset]  = (row * -1) - 1
    attributes[:limit]   = 1
  # postive value is an offset of current observation
  else
    attributes[:order]   = :desc
    attributes[:offset]  = row
    attributes[:limit]   = 1
  end
end