Class: PBXObject

Inherits:
Hash
  • Object
show all
Defined in:
lib/pbxplorer.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Hash

#to_pbx_plist

Constructor Details

#initialize(hash = {}, uuid = "") ⇒ PBXObject

Returns a new instance of PBXObject.



41
42
43
44
45
46
47
48
49
# File 'lib/pbxplorer.rb', line 41

def initialize hash={}, uuid=""
  24.times { uuid += "0123456789ABCDEF"[rand(16),1] } if uuid.empty?

  @project = nil
  @uuid = uuid

  self.merge! hash
  self["isa"] ||= self.class.to_s
end

Instance Attribute Details

#project_fileObject

Returns the value of attribute project_file.



26
27
28
# File 'lib/pbxplorer.rb', line 26

def project_file
  @project_file
end

#uuidObject (readonly)

Returns the value of attribute uuid.



27
28
29
# File 'lib/pbxplorer.rb', line 27

def uuid
  @uuid
end

Class Method Details

.filter(objs, attrs) ⇒ Object



29
30
31
32
33
# File 'lib/pbxplorer.rb', line 29

def self.filter objs, attrs
  objs.select do |obj|
    attrs.select { |key, val| obj[key] == val }.length == attrs.length
  end
end

.objects_of_class(objs, attrs = nil) ⇒ Object



35
36
37
38
39
# File 'lib/pbxplorer.rb', line 35

def self.objects_of_class objs, attrs=nil
 objs = objs.select { |obj| obj.class <= self }
 objs = self.filter(objs, attrs) if attrs
 objs
end

Instance Method Details

#helpObject



56
57
58
# File 'lib/pbxplorer.rb', line 56

def help
  puts "(no help available)"
end

#inspectObject



51
52
53
54
# File 'lib/pbxplorer.rb', line 51

def inspect
  props = self.map { |key, val| "  #{key} = #{val.inspect}\n" }
  "#{@uuid} = {\n#{props.join}}"
end