Class: MooTool::Models::DeviceTree

Inherits:
Object
  • Object
show all
Defined in:
lib/mootool/models/device_tree.rb

Defined Under Namespace

Classes: Node, Property

Constant Summary collapse

NODE_FORMAT =
'VV'
PROP_FORMAT =
'A32V'
PHANDLE_PROP =
'AAPL,phandle'
COMPATIBLE_PROP =
'compatible'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ DeviceTree

Returns a new instance of DeviceTree.

Parameters:



80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/mootool/models/device_tree.rb', line 80

def initialize(data)
  @handles = {}
  case data
  when Pathname
    @data = File.open(data.realpath, 'rb')
  when String
    @data = StringIO.new(data)
  when IO
    @data = data
  when MooTool::Models::Decompressor
    @data = StringIO.new data.data
  end
  @root = Node.new(self, @data)
end

Instance Attribute Details

#rootObject (readonly)

Returns the value of attribute root.



77
78
79
# File 'lib/mootool/models/device_tree.rb', line 77

def root
  @root
end

Class Method Details

.load(path) ⇒ Object



99
100
101
# File 'lib/mootool/models/device_tree.rb', line 99

def self.load(path)
  MooTool::Models::DeviceTree.new(Pathname.new(path))
end

Instance Method Details

#add_handle(node, handle) ⇒ Object



95
96
97
# File 'lib/mootool/models/device_tree.rb', line 95

def add_handle(node, handle)
  @handles[handle] = node
end

#to_hObject



103
104
105
# File 'lib/mootool/models/device_tree.rb', line 103

def to_h
  @root.to_h
end