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_plist

Constructor Details

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

Returns a new instance of PBXObject.



37
38
39
40
41
42
43
44
45
# File 'lib/pbxplorer.rb', line 37

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.



22
23
24
# File 'lib/pbxplorer.rb', line 22

def project_file
  @project_file
end

#uuidObject (readonly)

Returns the value of attribute uuid.



23
24
25
# File 'lib/pbxplorer.rb', line 23

def uuid
  @uuid
end

Class Method Details

.filter(objs, attrs) ⇒ Object



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

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



31
32
33
34
35
# File 'lib/pbxplorer.rb', line 31

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



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

def help
  puts "(no help available)"
end

#inspectObject



47
48
49
50
# File 'lib/pbxplorer.rb', line 47

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