Class: Valise::Item
Instance Attribute Summary collapse
-
#contents ⇒ Object
Returns the value of attribute contents.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#stack ⇒ Object
readonly
Returns the value of attribute stack.
Instance Method Summary collapse
- #dump_contents ⇒ Object
- #full_path ⇒ Object
-
#initialize(stack, root, dump_load) ⇒ Item
constructor
A new instance of Item.
- #inspect ⇒ Object
- #load_contents ⇒ Object
- #open(&block) ⇒ Object
- #present? ⇒ Boolean
- #raw_file ⇒ Object
- #save ⇒ Object
- #segments ⇒ Object
- #writable? ⇒ Boolean
Methods included from Unpath
Constructor Details
#initialize(stack, root, dump_load) ⇒ Item
Returns a new instance of Item.
46 47 48 49 50 51 |
# File 'lib/valise/item.rb', line 46 def initialize(stack, root, dump_load) @stack = stack @root = root @dump_load = dump_load || Serialization::Raw @contents = nil end |
Instance Attribute Details
#contents ⇒ Object
Returns the value of attribute contents.
54 55 56 |
# File 'lib/valise/item.rb', line 54 def contents @contents end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
53 54 55 |
# File 'lib/valise/item.rb', line 53 def root @root end |
#stack ⇒ Object (readonly)
Returns the value of attribute stack.
53 54 55 |
# File 'lib/valise/item.rb', line 53 def stack @stack end |
Instance Method Details
#dump_contents ⇒ Object
98 99 100 |
# File 'lib/valise/item.rb', line 98 def dump_contents @dump_load.dump(load_contents) #@contents? end |
#full_path ⇒ Object
64 65 66 |
# File 'lib/valise/item.rb', line 64 def full_path @root.full_path(segments) end |
#inspect ⇒ Object
56 57 58 |
# File 'lib/valise/item.rb', line 56 def inspect "#{@root.inspect}//#{@stack.inspect}" end |
#load_contents ⇒ Object
102 103 104 |
# File 'lib/valise/item.rb', line 102 def load_contents @contents ||= @dump_load.load(@root.get_from(self)) end |
#open(&block) ⇒ Object
80 81 82 |
# File 'lib/valise/item.rb', line 80 def open(&block) File::open(full_path, "r", &block) end |
#present? ⇒ Boolean
72 73 74 |
# File 'lib/valise/item.rb', line 72 def present? @root.present?(segments) end |
#raw_file ⇒ Object
76 77 78 |
# File 'lib/valise/item.rb', line 76 def raw_file File::open(full_path) end |
#save ⇒ Object
84 85 86 |
# File 'lib/valise/item.rb', line 84 def save root.write(self) end |
#segments ⇒ Object
60 61 62 |
# File 'lib/valise/item.rb', line 60 def segments @stack.segments end |
#writable? ⇒ Boolean
68 69 70 |
# File 'lib/valise/item.rb', line 68 def writable? @root.writable?(segments) end |