Class: AppleData::IORegClass

Inherits:
Object
  • Object
show all
Defined in:
lib/apple_data/ioreg.rb

Overview

A single IOKit class

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass_name) ⇒ IORegClass

Returns a new instance of IORegClass.



27
28
29
30
# File 'lib/apple_data/ioreg.rb', line 27

def initialize(klass_name)
  @name = klass_name
  @parents = []
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



25
26
27
# File 'lib/apple_data/ioreg.rb', line 25

def description
  @description
end

#known_namesObject

Returns the value of attribute known_names.



25
26
27
# File 'lib/apple_data/ioreg.rb', line 25

def known_names
  @known_names
end

#nameObject

Returns the value of attribute name.



25
26
27
# File 'lib/apple_data/ioreg.rb', line 25

def name
  @name
end

#parentsObject

Returns the value of attribute parents.



25
26
27
# File 'lib/apple_data/ioreg.rb', line 25

def parents
  @parents
end

Class Method Details

.for_name(name) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/apple_data/ioreg.rb', line 32

def self.for_name(name)
  @instances ||= {}

  @instances[name] = IORegClass.new name unless @instances.key? name

  @instances[name]
end

.load_one(hash) ⇒ Object



44
45
46
47
48
49
# File 'lib/apple_data/ioreg.rb', line 44

def self.load_one(hash)
  instance = for_name hash['name']
  instance.description = hash['description']
  instance.parents = hash['parents']
  instance.known_names = (hash['known_names'] || []).sort
end

.valuesObject



40
41
42
# File 'lib/apple_data/ioreg.rb', line 40

def self.values
  @instances.values.sort_by(&:name)
end

Instance Method Details

#to_hObject



51
52
53
# File 'lib/apple_data/ioreg.rb', line 51

def to_h
  { 'name' => @name, 'description' => @description, 'parents' => @parents, 'known_names' => @known_names }
end

#user_client?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/apple_data/ioreg.rb', line 55

def user_client?
  @parents.include? 'IOUserClient'
end