class Sequel::SQL::Subscript

  1. lib/sequel/sql.rb
Parent: SQL

Represents an SQL array access, with multiple possible arguments.

Methods

Public Class

  1. new

Public Instance

  1. []
  2. f
  3. sub
  4. |

Attributes

f [R]

The SQL array column

sub [R]

The array of subscripts to use (should be an array of numbers)

Public Class methods

new (f, sub)

Set the array column and subscripts to the given arguments

[show source]
# File lib/sequel/sql.rb, line 1475
def initialize(f, sub)
  @f, @sub = f, sub
end

Public Instance methods

[] (sub)

Create a new Subscript by accessing a subarray of a multidimensional array.

:a.sql_subscript(2) # a[2]
:a.sql_subscript(2)[1] # a[2][1]
[show source]
# File lib/sequel/sql.rb, line 1493
def [](sub)
  Subscript.new(self, Array(sub))
end
| (sub)

Create a new Subscript appending the given subscript(s) to the current array of subscripts.

:a.sql_subscript(2) # a[2]
:a.sql_subscript(2) | 1 # a[2, 1]
[show source]
# File lib/sequel/sql.rb, line 1484
def |(sub)
  Subscript.new(@f, @sub + Array(sub))
end