Class: Changi::Entry
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
included, #read_in_attributes
Constructor Details
#initialize(entry_set, path) ⇒ Entry
Returns a new instance of Entry.
22
23
24
25
|
# File 'lib/changi/entry.rb', line 22
def initialize entry_set, path
@entry_set = entry_set
@path = path
end
|
Instance Attribute Details
#entry_set ⇒ Object
Returns the value of attribute entry_set.
20
21
22
|
# File 'lib/changi/entry.rb', line 20
def entry_set
@entry_set
end
|
Class Method Details
.build(entry_set, yaml_path) ⇒ Object
8
9
10
|
# File 'lib/changi/entry.rb', line 8
def build entry_set, yaml_path
new(entry_set, yaml_path).tap(&:read_in_attributes)
end
|
.load(entry_set, yaml_path) ⇒ Object
12
13
14
|
# File 'lib/changi/entry.rb', line 12
def load entry_set, yaml_path
new(entry_set, yaml_path).tap(&:read_in_yaml)
end
|
Instance Method Details
#destroy ⇒ Object
36
37
38
|
# File 'lib/changi/entry.rb', line 36
def destroy
git_rm || file_rm
end
|
#read_in_yaml ⇒ Object
27
28
29
30
|
# File 'lib/changi/entry.rb', line 27
def read_in_yaml
data = YAML.load_file @path
self.class.attribute_names.each { |name| send "#{name}=".to_sym, data[name] }
end
|
#save ⇒ Object
32
33
34
|
# File 'lib/changi/entry.rb', line 32
def save
File.open(@path, 'w') { |fd| fd.puts to_yaml }
end
|