Class: OSA::ObjectSpecifierList
- Inherits:
-
Object
- Object
- OSA::ObjectSpecifierList
- Includes:
- Enumerable
- Defined in:
- lib/rubyosa/rbosa.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
- #[](idx) ⇒ Object
- #each ⇒ Object
- #empty? ⇒ Boolean
- #every(sym) ⇒ Object
- #first ⇒ Object
- #get ⇒ Object (also: #to_a)
-
#initialize(app, desired_class, container) ⇒ ObjectSpecifierList
constructor
A new instance of ObjectSpecifierList.
- #inspect ⇒ Object
- #last ⇒ Object
- #length ⇒ Object (also: #size)
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 |
#each ⇒ Object
199 200 201 |
# File 'lib/rubyosa/rbosa.rb', line 199 def each self.length.times { |i| yield(self[i]) } end |
#empty? ⇒ 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 |
#first ⇒ Object
191 192 193 |
# File 'lib/rubyosa/rbosa.rb', line 191 def first self[0] end |
#get ⇒ Object 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 |
#inspect ⇒ Object
217 218 219 |
# File 'lib/rubyosa/rbosa.rb', line 217 def inspect super.scan(/^([^ ]+)/).to_s << " desired_class=#{@desired_class}>" end |
#last ⇒ Object
195 196 197 |
# File 'lib/rubyosa/rbosa.rb', line 195 def last self[-1] end |