Class: VersionInfo::Storage
- Inherits:
-
Object
- Object
- VersionInfo::Storage
show all
- Defined in:
- lib/version_info/storage.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(data) ⇒ Storage
Returns a new instance of Storage.
5
6
7
8
9
|
# File 'lib/version_info/storage.rb', line 5
def initialize(data)
super()
@data = data
load if file_name && File.exist?(file_name)
end
|
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
3
4
5
|
# File 'lib/version_info/storage.rb', line 3
def data
@data
end
|
Instance Method Details
#file_name ⇒ Object
11
12
13
|
# File 'lib/version_info/storage.rb', line 11
def file_name
@file_name ||= Dir.pwd + '/' + default_file_name
end
|
#file_name=(value) ⇒ Object
15
16
17
|
# File 'lib/version_info/storage.rb', line 15
def file_name=(value)
@file_name = value
end
|
#load ⇒ Object
19
20
21
22
|
# File 'lib/version_info/storage.rb', line 19
def load
File.open(file_name, 'r') {|io| load_from(io)}
self
end
|
#save ⇒ Object
24
25
26
27
|
# File 'lib/version_info/storage.rb', line 24
def save
File.open(file_name, 'w' ) {|out| save_to(out)}
self
end
|