Module: Rmega::Nodes::Traversable

Included in:
Folder, Node, Root, Trash
Defined in:
lib/rmega/nodes/traversable.rb

Instance Method Summary collapse

Instance Method Details

#childrenObject


4
5
6
# File 'lib/rmega/nodes/traversable.rb', line 4

def children
  storage.nodes.select { |node| node.parent_handle == handle }
end

#empty?Boolean

Returns:

  • (Boolean)

21
22
23
# File 'lib/rmega/nodes/traversable.rb', line 21

def empty?
  children.size == 0
end

#filesObject


12
13
14
# File 'lib/rmega/nodes/traversable.rb', line 12

def files
  children.select { |node| node.type == :file }
end

#foldersObject


8
9
10
# File 'lib/rmega/nodes/traversable.rb', line 8

def folders
  children.select { |node| node.type == :folder }
end

#parentObject


16
17
18
19
# File 'lib/rmega/nodes/traversable.rb', line 16

def parent
  return unless parent_handle
  storage.nodes.find { |node| node.handle == parent_handle }
end