# Cloud Spanner API - Class Google::Cloud::Spanner::Range (v2.36.0)

2.36.0 (latest) 2.35.0 2.34.0 2.33.0 2.32.0 2.31.0 2.30.0 2.29.0 2.28.0 2.27.0 2.26.0 2.25.0 2.24.0 2.23.0 2.22.0 2.21.0 2.20.0 2.19.1 2.18.1 2.17.0 2.16.1 2.15.0 2.14.0 2.13.0 2.12.1 2.11.0 Reference documentation and code samples for the Cloud Spanner API class Google::Cloud::Spanner::Range.

## Range

Represents a range of rows in a table or index. A range has a start key
and an end key. These keys can be open or closed, indicating if the
range includes rows with that key.

## Inherits

- Object

## Example

```ruby
require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

db = spanner.client "my-instance", "my-database"

key_range = db.range 1, 100
results = db.read "users", [:id, :name], keys: key_range

results.rows.each do |row|
  puts "User #{row[:id]} is #{row[:name]}"
end
```

## Methods

### #begin

    def begin()

Returns the object that defines the beginning of the range.

### #end

    def end()

Returns the object that defines the end of the range.

### #exclude_begin?

    def exclude_begin?() -> Boolean

Returns `true` if the range excludes its beginning value.
**Returns**

- (Boolean)

### #exclude_end?

    def exclude_end?() -> Boolean

Returns `true` if the range excludes its end value.
**Returns**

- (Boolean)

### #initialize

    def initialize(beginning, ending, exclude_begin: false, exclude_end: false) -> Range

Creates a Spanner Range. This can be used in place of a Ruby Range
when needing to exclude the beginning value.
**Parameters**

- **beginning** (Object) --- The object that defines the beginning of the range.
- **ending** (Object) --- The object that defines the end of the range.
- **exclude_begin** (Boolean) *(defaults to: false)* --- Determines if the range excludes its beginning value. Default is `false`.
- **exclude_end** (Boolean) *(defaults to: false)* --- Determines if the range excludes its ending value. Default is `false`.
**Returns**

- ([Range](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-spanner/latest/Google-Cloud-Spanner-Range)) --- a new instance of Range
**Example**

```ruby
require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

db = spanner.client "my-instance", "my-database"

key_range = Google::Cloud::Spanner::Range.new 1, 100
results = db.read "users", [:id, :name], keys: key_range

results.rows.each do |row|
  puts "User #{row[:id]} is #{row[:name]}"
end
```