Class: Ro::Root
Instance Method Summary
collapse
Methods inherited from Path
#<=>, absolute, #absolute, absolute?, #base, #basename, #binwrite, #child?, clean, #detect, #directory?, expand, #extension, #file?, #files, #glob, #initialize, #join, #key, #klass, #parent, #parent?, #parts, #pn, #relative, relative, relative?, #relative_from, #relative_to, #relative_to!, #select, #sibling?, #sort_key, #stat, #subdirectories, #subdirectory?, #subdirectory_for
Methods included from Klass
included
Methods inherited from String
#html_safe
Constructor Details
This class inherits a constructor from Ro::Path
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, **kws, &block) ⇒ Object
69
70
71
|
# File 'lib/ro/root.rb', line 69
def method_missing(name, *args, **kws, &block)
get(name) || super
end
|
Instance Method Details
53
54
55
|
# File 'lib/ro/root.rb', line 53
def [](name)
get(name)
end
|
#collection_for(subdirectory) ⇒ Object
18
19
20
|
# File 'lib/ro/root.rb', line 18
def collection_for(subdirectory)
Collection.new(subdirectory)
end
|
#collections(&block) ⇒ Object
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/ro/root.rb', line 7
def collections(&block)
accum = Collection::List.for(self)
subdirectories do |subdirectory|
collection = collection_for(subdirectory)
block ? block.call(collection) : accum.push(collection)
end
block ? self : accum
end
|
#get(name) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/ro/root.rb', line 30
def get(name)
name = name.to_s
if name.index('/')
collection_name, node_name = name.split('/', 2)
collection = get(collection_name)
if collection
node = collection.get(node_name)
return node
else
return nil
end
end
paths_for(name).each do |path|
next unless path.directory?
return collection_for(path)
end
nil
end
|
#identifier ⇒ Object
3
4
5
|
# File 'lib/ro/root.rb', line 3
def identifier
self
end
|
#nodes(&block) ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/ro/root.rb', line 57
def nodes(&block)
accum = []
collections.each do |collection|
collection.nodes do |node|
block ? block.call(node) : accum.push(node)
end
end
block ? self : accum
end
|
#paths_for(name) ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/ro/root.rb', line 22
def paths_for(name)
[
subdirectory_for(name),
subdirectory_for(Slug.for(name, :join => '-')),
subdirectory_for(Slug.for(name, :join => '_')),
]
end
|