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.



166
167
168
# File 'lib/rubyosa/rbosa.rb', line 166

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

Instance Method Details

#==(other) ⇒ Object



209
210
211
212
213
# File 'lib/rubyosa/rbosa.rb', line 209

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



182
183
184
185
186
187
# File 'lib/rubyosa/rbosa.rb', line 182

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



197
198
199
# File 'lib/rubyosa/rbosa.rb', line 197

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

#empty?Boolean

Returns:

  • (Boolean)


178
179
180
# File 'lib/rubyosa/rbosa.rb', line 178

def empty?
  length == 0
end

#every(sym) ⇒ Object



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

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



189
190
191
# File 'lib/rubyosa/rbosa.rb', line 189

def first
  self[0]
end

#getObject Also known as: to_a



201
202
203
204
205
206
# File 'lib/rubyosa/rbosa.rb', line 201

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



215
216
217
# File 'lib/rubyosa/rbosa.rb', line 215

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

#lastObject



193
194
195
# File 'lib/rubyosa/rbosa.rb', line 193

def last
  self[-1]
end

#lengthObject Also known as: size



170
171
172
173
174
175
# File 'lib/rubyosa/rbosa.rb', line 170

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