class Xcodeproj::Project::PBXObjectList
In case ‘scoped` is an Array the list’s order is maintained.
def ==(other)
def ==(other) self.to_a == other.to_a end
def [](uuid)
def [](uuid) if uuid_scope.include?(uuid) && hash = @project.objects_hash[uuid] Object.const_get(hash['isa']).new(@project, uuid, hash) end end
def add(klass, hash = {})
def add(klass, hash = {}) object = klass.new(@project, nil, hash) self << object object end
def each
def each uuid_scope.each do |uuid| yield self[uuid] end end
def empty?
def empty? uuid_scope.empty? end
def first
def first to_a.first end
def initialize(represented_class, project)
def initialize(represented_class, project) @represented_class = represented_class @project = project @callbacks = {} yield self if block_given? end
def inspect
def inspect "<PBXObjectList: #{map(&:inspect).join(', ')}>" end
def last
def last to_a.last end
def let(callback_name, &block)
* :uuid_scope Returns the list of UUIDs to scope this list to.
Specify callbacks for:
def let(callback_name, &block) raise ArgumentError, "Incorrect callback `#{callback_name}'." unless [:uuid_scope, :push].include?(callback_name) @callbacks[callback_name] = block end
def list_by_class(klass)
-
(PBXObjectList- The list of matching objects.)
Other tags:
- Yield: - The list instance, allowing you to
Parameters:
-
klass(AbstractPBXObject) -- The AbstractPBXObject subclass to
def list_by_class(klass) parent = self PBXObjectList.new(klass, @project) do |list| list.let(:push) do |object| # Objects added to the subselection should still use the same # callback as this list. parent << object end list.let(:uuid_scope) do parent.uuid_scope.select do |uuid| @project.objects_hash[uuid]['isa'] == klass.isa end end yield list if block_given? end end
def method_missing(name, *args, &block)
def method_missing(name, *args, &block) if @represented_class.respond_to?(name) object = @represented_class.send(name, @project, *args) # The callbacks are only for AbstractPBXObject instances instantiated # from the class method that we forwarded the message to. self << object if object.is_a?(Object::AbstractPBXObject) object else super end end
def new(hash = {})
def new(hash = {}) add(@represented_class, hash) end
def object_named(name)
- Todo: - is it really necessary to have an extra method for this?
def object_named(name) where :name => name end
def push(object)
Run Ruby in debug mode to receive warnings about calls to :push when a
def push(object) if @callbacks[:push] @callbacks[:push].call(object) else if $DEBUG warn "Pushed object onto a PBXObjectList that does not have a :push callback from: #{caller.first}" end end self end
def size
def size uuid_scope.size end
def uuid_scope
def uuid_scope @callbacks[:uuid_scope].call end
def where(attributes)
def where(attributes) find { |o| o.matches_attributes?(attributes) } end