Class: Valise::Item
- Inherits:
-
Object
show all
- Includes:
- Unpath
- Defined in:
- lib/valise/item.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Unpath
#collapse, file_from_backtrace, #file_from_backtrace, #from_here, from_here, repath, string_to_segments, unpath, up_to, #up_to
Constructor Details
#initialize(stack, root, dump_load) ⇒ Item
Returns a new instance of Item.
9
10
11
12
13
14
|
# File 'lib/valise/item.rb', line 9
def initialize(stack, root, dump_load)
@stack = stack
@root = root
@dump_load = dump_load
@contents = nil
end
|
Instance Attribute Details
#contents ⇒ Object
Returns the value of attribute contents.
17
18
19
|
# File 'lib/valise/item.rb', line 17
def contents
@contents
end
|
#root ⇒ Object
Returns the value of attribute root.
16
17
18
|
# File 'lib/valise/item.rb', line 16
def root
@root
end
|
#stack ⇒ Object
Returns the value of attribute stack.
16
17
18
|
# File 'lib/valise/item.rb', line 16
def stack
@stack
end
|
Instance Method Details
#depth ⇒ Object
23
24
25
|
# File 'lib/valise/item.rb', line 23
def depth
@stack.depth_of(self)
end
|
#dump_contents ⇒ Object
73
74
75
|
# File 'lib/valise/item.rb', line 73
def dump_contents
@dump_load.dump(self) end
|
#full_path ⇒ Object
35
36
37
|
# File 'lib/valise/item.rb', line 35
def full_path
@root.full_path(segments)
end
|
#inspect ⇒ Object
19
20
21
|
# File 'lib/valise/item.rb', line 19
def inspect
"#{@root.inspect}//#{@stack.inspect}"
end
|
#load_contents ⇒ Object
77
78
79
|
# File 'lib/valise/item.rb', line 77
def load_contents
@contents ||= @dump_load.load(self)
end
|
#open(&block) ⇒ Object
55
56
57
|
# File 'lib/valise/item.rb', line 55
def open(&block)
File::open(full_path, "r", &block)
end
|
#present? ⇒ Boolean
43
44
45
|
# File 'lib/valise/item.rb', line 43
def present?
@root.present?(segments)
end
|
#raw_contents ⇒ Object
51
52
53
|
# File 'lib/valise/item.rb', line 51
def raw_contents
@root.get_from(self)
end
|
#raw_file ⇒ Object
47
48
49
|
# File 'lib/valise/item.rb', line 47
def raw_file
File::open(full_path)
end
|
#rel_path ⇒ Object
31
32
33
|
# File 'lib/valise/item.rb', line 31
def rel_path
@stack.rel_path
end
|
#save ⇒ Object
59
60
61
|
# File 'lib/valise/item.rb', line 59
def save
root.write(self)
end
|
#segments ⇒ Object
27
28
29
|
# File 'lib/valise/item.rb', line 27
def segments
@stack.segments
end
|
#writable? ⇒ Boolean
39
40
41
|
# File 'lib/valise/item.rb', line 39
def writable?
@root.writable?(segments)
end
|