Class: OracleDB::Lob
- Inherits:
-
Object
- Object
- OracleDB::Lob
- Defined in:
- lib/oracledb.rb,
ext/oracledb/rboradb_lob.c
Instance Method Summary collapse
- #chunk_size ⇒ Object
- #close ⇒ Object
- #close_resource ⇒ Object
- #directory_and_file_name ⇒ Object
- #file_exists ⇒ Object
-
#initialize(conn, type, value = nil) ⇒ Lob
constructor
A new instance of Lob.
- #is_resource_open ⇒ Object
- #open_resource ⇒ Object
- #read(length = nil) ⇒ Object
- #seek(offset, whence = IO::SEEK_SET) ⇒ Object
- #set(value) ⇒ Object
- #set_directory_and_file_name(directory_alias, file_name) ⇒ Object
- #size ⇒ Object
- #trim(new_size) ⇒ Object
- #type ⇒ Object
- #write(value) ⇒ Object
Constructor Details
#initialize(conn, type, value = nil) ⇒ Lob
Returns a new instance of Lob.
42 43 44 45 |
# File 'lib/oracledb.rb', line 42 def initialize(conn, type, value = nil) __initialize(conn, type) set(value) end |
Instance Method Details
#chunk_size ⇒ Object
132 133 134 135 |
# File 'ext/oracledb/rboradb_lob.c', line 132
static VALUE lob_chunk_size(VALUE self)
{
GET_UINT32(Lob, ChunkSize);
}
|
#close ⇒ Object
112 113 114 115 116 117 118 119 120 |
# File 'ext/oracledb/rboradb_lob.c', line 112
static VALUE lob_close(VALUE self)
{
Lob_t *lob = To_Lob(self);
if (dpiLob_close(lob->handle) != DPI_SUCCESS) {
RBORADB_RAISE_ERROR(lob);
}
return Qnil;
}
|
#close_resource ⇒ Object
122 123 124 125 126 127 128 129 130 |
# File 'ext/oracledb/rboradb_lob.c', line 122
static VALUE lob_close_resource(VALUE self)
{
Lob_t *lob = To_Lob(self);
if (dpiLob_closeResource(lob->handle) != DPI_SUCCESS) {
RBORADB_RAISE_ERROR(lob);
}
return Qnil;
}
|
#directory_and_file_name ⇒ Object
137 138 139 140 141 142 143 144 145 146 147 |
# File 'ext/oracledb/rboradb_lob.c', line 137
static VALUE lob_directory_and_file_name(VALUE self)
{
Lob_t *lob = To_Lob(self);
const char *dir, *file;
uint32_t dlen, flen;
if (dpiLob_getDirectoryAndFileName(lob->handle, &dir, &dlen, &file, &flen) != DPI_SUCCESS) {
RBORADB_RAISE_ERROR(lob);
}
return rb_ary_new_from_args(2, rb_enc_str_new(dir, dlen, rb_utf8_encoding()), rb_enc_str_new(file, flen, rb_utf8_encoding()));
}
|
#file_exists ⇒ Object
149 150 151 152 |
# File 'ext/oracledb/rboradb_lob.c', line 149
static VALUE lob_file_exists(VALUE self)
{
GET_BOOL(Lob, FileExists);
}
|
#is_resource_open ⇒ Object
154 155 156 157 |
# File 'ext/oracledb/rboradb_lob.c', line 154
static VALUE lob_is_resource_open(VALUE self)
{
GET_BOOL(Lob, IsResourceOpen);
}
|
#open_resource ⇒ Object
169 170 171 172 173 174 175 176 177 |
# File 'ext/oracledb/rboradb_lob.c', line 169
static VALUE lob_open_resource(VALUE self)
{
Lob_t *lob = To_Lob(self);
if (dpiLob_openResource(lob->handle) != DPI_SUCCESS) {
RBORADB_RAISE_ERROR(lob);
}
return Qnil;
}
|
#read(length = nil) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/oracledb.rb', line 52 def read(length = nil) return "" if length.zero? len = length if length.nil? len = size - @pos return "" if len <= 0 end value, len = __read_bytes(@pos + 1, len) if len > 0 @pos += len value elsif length.nil? "" else nil end end |
#seek(offset, whence = IO::SEEK_SET) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/oracledb.rb', line 70 def seek(offset, whence = IO::SEEK_SET) case whence when IO::SEEK_SET, :SET @pos = offset when IO::SEEK_CUR, :CUR @pos += offset when IO::SEEK_END, :END @pos = size + offset else raise ArgumentError, "Unkown whence value: #{whence}" end 0 end |
#set(value) ⇒ Object
47 48 49 50 |
# File 'lib/oracledb.rb', line 47 def set(value) len = __set_from_bytes(value) @pos = len end |
#set_directory_and_file_name(directory_alias, file_name) ⇒ Object
208 209 210 211 212 213 214 215 216 217 218 |
# File 'ext/oracledb/rboradb_lob.c', line 208
static VALUE lob_set_directory_and_file_name(VALUE self, VALUE directory_alias, VALUE file_name)
{
Lob_t *lob = To_Lob(self);
ExportString(directory_alias);
ExportString(file_name);
if (dpiLob_setDirectoryAndFileName(lob->handle, RSTRING_PTR(directory_alias), RSTRING_LEN(directory_alias), RSTRING_PTR(file_name), RSTRING_LEN(file_name)) != DPI_SUCCESS) {
RBORADB_RAISE_ERROR(lob);
}
return Qnil;
}
|
#size ⇒ Object
159 160 161 162 |
# File 'ext/oracledb/rboradb_lob.c', line 159
static VALUE lob_size(VALUE self)
{
GET_UINT64(Lob, Size);
}
|
#trim(new_size) ⇒ Object
220 221 222 223 224 225 226 227 228 |
# File 'ext/oracledb/rboradb_lob.c', line 220
static VALUE lob_trim(VALUE self, VALUE new_size)
{
Lob_t *lob = To_Lob(self);
if (dpiLob_trim(lob->handle, NUM2ULL(new_size)) != DPI_SUCCESS) {
RBORADB_RAISE_ERROR(lob);
}
return Qnil;
}
|
#type ⇒ Object
164 165 166 167 |
# File 'ext/oracledb/rboradb_lob.c', line 164
static VALUE lob_type(VALUE self)
{
GET_ENUM(Lob, Type, dpiOracleTypeNum);
}
|
#write(value) ⇒ Object
84 85 86 87 88 |
# File 'lib/oracledb.rb', line 84 def write(value) len = __write_bytes(@pos + 1, value) @pos += len len end |