Class: OSA::ObjectSpecifierList

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/rubyosa/rbosa.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, desired_class, container) ⇒ ObjectSpecifierList

Returns a new instance of ObjectSpecifierList.



168
169
170
# File 'lib/rubyosa/rbosa.rb', line 168

def initialize(app, desired_class, container)
  @app, @desired_class, @container = app, desired_class, container
end

Instance Method Details

#==(other) ⇒ Object



211
212
213
214
215
# File 'lib/rubyosa/rbosa.rb', line 211

def ==(other)
  other.kind_of?(self.class) \
  and other.length == self.length \
  and (0..other.length).all? { |i| other[i] == self[i] }
end

#[](idx) ⇒ Object



184
185
186
187
188
189
# File 'lib/rubyosa/rbosa.rb', line 184

def [](idx)
  idx += 1 # AE starts counting at 1.
  o = obj_spec_with_key(OSA::Element.__new__('long', [idx].pack('l')))
  o.instance_variable_set(:@app, @app)
  o.extend OSA::ObjectSpecifier
end

#eachObject



199
200
201
# File 'lib/rubyosa/rbosa.rb', line 199

def each
  self.length.times { |i| yield(self[i]) }
end

#empty?Boolean

Returns:

  • (Boolean)


180
181
182
# File 'lib/rubyosa/rbosa.rb', line 180

def empty?
  length == 0
end

#every(sym) ⇒ Object



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# File 'lib/rubyosa/rbosa.rb', line 221

def every(sym)
  if @desired_class.method_defined?(sym) and code = OSA.sym_to_code(sym)
    o = obj_spec_with_key(OSA::Element.__new__('abso', 'all '.to_4cc))
    pklass = @app.classes[code]
    if pklass.nil? or !OSA.lazy_events
      @app.__send_event__('core', 'getd', 
        [['----', OSA::Element.__new_object_specifier__('prop', o,
        'prop', OSA::Element.__new__('type', code.to_4cc))]],
        true).to_rbobj
    else
      OSA::ObjectSpecifierList.new(@app, pklass, o)
    end
  else
    raise ArgumentError, "desired class `#{@desired_class}' does not have a attribute named `#{sym.to_s}'"
  end
end

#firstObject



191
192
193
# File 'lib/rubyosa/rbosa.rb', line 191

def first
  self[0]
end

#getObject Also known as: to_a



203
204
205
206
207
208
# File 'lib/rubyosa/rbosa.rb', line 203

def get
  o = obj_spec_with_key(OSA::Element.__new__('abso', 'all '.to_4cc))
  o.instance_variable_set(:@app, @app)
  o.extend OSA::ObjectSpecifier
  o.get
end

#inspectObject



217
218
219
# File 'lib/rubyosa/rbosa.rb', line 217

def inspect
  super.scan(/^([^ ]+)/).to_s << " desired_class=#{@desired_class}>"
end

#lastObject



195
196
197
# File 'lib/rubyosa/rbosa.rb', line 195

def last
  self[-1]
end

#lengthObject Also known as: size



172
173
174
175
176
177
# File 'lib/rubyosa/rbosa.rb', line 172

def length
  @app.__send_event__(
    'core', 'cnte', 
    [['----', @container], ['kocl', OSA::Element.__new__('type', @desired_class::CODE.to_4cc)]], 
    true).to_rbobj
end