Class: Jackcess::Index
- Inherits:
-
Object
- Object
- Jackcess::Index
- Defined in:
- lib/jackcess/index.rb
Overview
Represents an index on a table in an Access database.
Indexes provide fast lookups and enforce uniqueness constraints. This class wraps Jackcess’s Index object to provide a Ruby-friendly interface.
Instance Attribute Summary collapse
-
#java_index ⇒ Java::ComHealthmarketscienceJackcess::Index
readonly
The underlying Java index object from Jackcess.
Instance Method Summary collapse
-
#columns ⇒ Array<String>
Returns an array of column names that comprise this index.
-
#ignore_nulls? ⇒ Boolean
Checks whether this index ignores null values.
-
#initialize(java_index) ⇒ Index
constructor
private
Creates a new Index instance wrapping a Java index object.
- #inspect ⇒ Object
-
#name ⇒ String
Returns the name of the index.
-
#primary_key? ⇒ Boolean
Checks whether this index is the table’s primary key.
- #to_s ⇒ Object
-
#unique? ⇒ Boolean
Checks whether this index enforces uniqueness.
Constructor Details
#initialize(java_index) ⇒ Index
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a new Index instance wrapping a Java index object.
25 26 27 |
# File 'lib/jackcess/index.rb', line 25 def initialize(java_index) @java_index = java_index end |
Instance Attribute Details
#java_index ⇒ Java::ComHealthmarketscienceJackcess::Index (readonly)
The underlying Java index object from Jackcess
19 20 21 |
# File 'lib/jackcess/index.rb', line 19 def java_index @java_index end |
Instance Method Details
#columns ⇒ Array<String>
Returns an array of column names that comprise this index.
45 46 47 |
# File 'lib/jackcess/index.rb', line 45 def columns @java_index.get_columns.map(&:get_name) end |
#ignore_nulls? ⇒ Boolean
Checks whether this index ignores null values.
When true, null values in indexed columns are not included in the index.
77 78 79 |
# File 'lib/jackcess/index.rb', line 77 def ignore_nulls? @java_index.should_ignore_nulls end |
#inspect ⇒ Object
81 82 83 |
# File 'lib/jackcess/index.rb', line 81 def inspect "#<Jackcess::Index name=#{name.inspect} columns=#{columns.inspect} primary_key=#{primary_key?}>" end |
#name ⇒ String
Returns the name of the index.
35 36 37 |
# File 'lib/jackcess/index.rb', line 35 def name @java_index.get_name end |
#primary_key? ⇒ Boolean
Checks whether this index is the table’s primary key.
55 56 57 |
# File 'lib/jackcess/index.rb', line 55 def primary_key? @java_index.is_primary_key end |
#to_s ⇒ Object
85 86 87 |
# File 'lib/jackcess/index.rb', line 85 def to_s "#{name}: #{columns.join(', ')}" end |
#unique? ⇒ Boolean
Checks whether this index enforces uniqueness.
65 66 67 |
# File 'lib/jackcess/index.rb', line 65 def unique? @java_index.is_unique end |