Class: Valise::Stack
- Inherits:
-
Object
show all
- Includes:
- ItemEnum, Unpath
- Defined in:
- lib/valise/stack.rb,
lib/valise/stack/extensions-decorator.rb
Defined Under Namespace
Classes: ExtensionsDecorator
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from ItemEnum
#absent, #present, #writable
Methods included from Unpath
#collapse, #file_from_backtrace, #from_here, from_here, #repath, #string_to_segments, #unpath, #up_to, up_to
Constructor Details
#initialize(path, set) ⇒ Stack
Returns a new instance of Stack.
15
16
17
18
|
# File 'lib/valise/stack.rb', line 15
def initialize(path, set)
@segments = collapse(unpath(path))
@valise = set
end
|
Instance Attribute Details
#segments ⇒ Object
Returns the value of attribute segments.
20
21
22
|
# File 'lib/valise/stack.rb', line 20
def segments
@segments
end
|
#valise ⇒ Object
Returns the value of attribute valise.
20
21
22
|
# File 'lib/valise/stack.rb', line 20
def valise
@valise
end
|
Instance Method Details
#below(item) ⇒ Object
46
47
48
|
# File 'lib/valise/stack.rb', line 46
def below(item)
reget(valise.below(item.root))
end
|
#depth_of(item) ⇒ Object
54
55
56
|
# File 'lib/valise/stack.rb', line 54
def depth_of(item)
valise.depth_of(item.root)
end
|
#diffed(item, value) ⇒ Object
38
39
40
|
# File 'lib/valise/stack.rb', line 38
def diffed(item, value)
merge_diff.diff(item, value)
end
|
#dump_load ⇒ Object
30
31
32
|
# File 'lib/valise/stack.rb', line 30
def dump_load
@valise.serialization_for(self)
end
|
#each ⇒ Object
78
79
80
81
82
|
# File 'lib/valise/stack.rb', line 78
def each
valise.each do |root|
yield(item_for(root))
end
end
|
#exts(*extensions) ⇒ Object
64
65
66
67
68
|
# File 'lib/valise/stack.rb', line 64
def exts(*extensions)
exts = ExtensionsDecorator.new(self)
exts.extensions = extensions
return exts
end
|
#find ⇒ Object
58
59
60
61
62
|
# File 'lib/valise/stack.rb', line 58
def find
item = present.first
return item unless item.nil?
raise Errors::NotFound, "#{rel_path} not found in #{@valise.inspect}"
end
|
#inspect ⇒ Object
11
12
13
|
# File 'lib/valise/stack.rb', line 11
def inspect
"<default>:#{(@segments||%w{?}).join "/"} #{@valise.inspect}"
end
|
#item_for(root) ⇒ Object
74
75
76
|
# File 'lib/valise/stack.rb', line 74
def item_for(root)
Item.new(self, root, dump_load)
end
|
#merge_diff ⇒ Object
26
27
28
|
# File 'lib/valise/stack.rb', line 26
def merge_diff
@valise.merge_diff_for(self)
end
|
#merged(item) ⇒ Object
34
35
36
|
# File 'lib/valise/stack.rb', line 34
def merged(item)
merge_diff.merge(item)
end
|
#not_above(item) ⇒ Object
42
43
44
|
# File 'lib/valise/stack.rb', line 42
def not_above(item)
reget(valise.not_above(item.root))
end
|
#reget(root) ⇒ Object
70
71
72
|
# File 'lib/valise/stack.rb', line 70
def reget(root)
root.get(@segments)
end
|
#rel_path ⇒ Object
22
23
24
|
# File 'lib/valise/stack.rb', line 22
def rel_path
repath(@segments)
end
|
#reverse ⇒ Object
50
51
52
|
# File 'lib/valise/stack.rb', line 50
def reverse
reget(valise.reverse)
end
|