Module: ODPI::Object::NamedCollection

Defined in:
lib/odpi/object.rb

Instance Method Summary collapse

Instance Method Details

#<<(val) ⇒ Object


135
136
137
138
# File 'lib/odpi/object.rb', line 135

def <<(val)
  val = val.nil? ? nil : @bindclass.convert_in(@conn, val)
  @object.append_element(val, @bindclass::TYPES[1])
end

#[](idx) ⇒ Object


125
126
127
128
# File 'lib/odpi/object.rb', line 125

def [](idx)
  val = @object.element_value_by_index(idx, @bindclass::TYPES[1])
  val.nil? ? nil : @bindclass.convert_out(@conn, val)
end

#[]=(idx, val) ⇒ Object


130
131
132
133
# File 'lib/odpi/object.rb', line 130

def []=(idx, val)
  val = val.nil? ? nil : @bindclass.convert_in(@conn, val)
  @object.set_element_value_by_index(idx, @bindclass::TYPES[1], val)
end

#delete_at(idx) ⇒ Object


140
141
142
# File 'lib/odpi/object.rb', line 140

def delete_at(idx)
  @object.delete_element_by_index(idx)
end

#exists_at?(idx) ⇒ Boolean

Returns:

  • (Boolean)

144
145
146
# File 'lib/odpi/object.rb', line 144

def exists_at?(idx)
  @object.element_exists_by_index?(idx)
end

#indexesObject


95
96
97
98
99
100
101
102
103
# File 'lib/odpi/object.rb', line 95

def indexes
  ary = []
  idx = @object.first_index
  while idx
    ary << idx
    idx = @object.next_index(idx)
  end
  ary
end

#to_aryObject


115
116
117
118
119
120
121
122
123
# File 'lib/odpi/object.rb', line 115

def to_ary
  ary = []
  idx = @object.first_index
  while idx
    ary.push(self[idx])
    idx = @object.next_index(idx)
  end
  ary
end

#to_hashObject


105
106
107
108
109
110
111
112
113
# File 'lib/odpi/object.rb', line 105

def to_hash
  hash = {}
  idx = @object.first_index
  while idx
    hash[idx] = self[idx]
    idx = @object.next_index(idx)
  end
  hash
end

#trim(num) ⇒ Object


148
149
150
# File 'lib/odpi/object.rb', line 148

def trim(num)
  @object.trim(num)
end