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.
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 |
#each ⇒ Object
197 198 199 |
# File 'lib/rubyosa/rbosa.rb', line 197 def each self.length.times { |i| yield(self[i]) } end |
#empty? ⇒ 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 |
#first ⇒ Object
189 190 191 |
# File 'lib/rubyosa/rbosa.rb', line 189 def first self[0] end |
#get ⇒ Object 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 |
#inspect ⇒ Object
215 216 217 |
# File 'lib/rubyosa/rbosa.rb', line 215 def inspect super.scan(/^([^ ]+)/).to_s << " desired_class=#{@desired_class}>" end |
#last ⇒ Object
193 194 195 |
# File 'lib/rubyosa/rbosa.rb', line 193 def last self[-1] end |