Class: UpnpContentExplorer::Explorer

Inherits:
Object
  • Object
show all
Defined in:
lib/upnp_content_explorer/explorer.rb

Instance Method Summary collapse

Constructor Details

#initialize(service) ⇒ Explorer

Returns a new instance of Explorer.



11
12
13
14
# File 'lib/upnp_content_explorer/explorer.rb', line 11

def initialize(service)
  @service = service
  @root = Node.new({title: 'Root', id: 0})
end

Instance Method Details

#children_of(path) ⇒ Object



20
21
22
# File 'lib/upnp_content_explorer/explorer.rb', line 20

def children_of(path)
  node_at(path).children
end

#items_of(path) ⇒ Object



24
25
26
# File 'lib/upnp_content_explorer/explorer.rb', line 24

def items_of(path)
  node_at(path).items
end

#node_at(path) ⇒ Object



16
17
18
# File 'lib/upnp_content_explorer/explorer.rb', line 16

def node_at(path)
  find_terminal_node(prepare_path(path))
end

#scrape(path) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/upnp_content_explorer/explorer.rb', line 28

def scrape(path)
  node = find_terminal_node(prepare_path(path))

  child_items = node.children.map do |child|
    scrape("#{path}/#{child.title}")
  end

  all_items = []
  all_items += node.items
  all_items += child_items.flatten
end