Class: DiffNews::FileHistory
- Inherits:
-
DefaultHistory
- Object
- DefaultHistory
- DiffNews::FileHistory
- Defined in:
- lib/file_history.rb
Instance Attribute Summary collapse
-
#revisions ⇒ Object
readonly
Returns the value of attribute revisions.
Instance Method Summary collapse
- #file_path(extension) ⇒ Object
-
#initialize(provider, uuid, url) ⇒ FileHistory
constructor
A new instance of FileHistory.
- #load ⇒ Object
- #store ⇒ Object
Methods inherited from DefaultHistory
#append_changed_revision, #clear, #revision_changed?
Constructor Details
#initialize(provider, uuid, url) ⇒ FileHistory
Returns a new instance of FileHistory.
13 14 15 |
# File 'lib/file_history.rb', line 13 def initialize provider, uuid, url super provider, uuid, url end |
Instance Attribute Details
#revisions ⇒ Object (readonly)
Returns the value of attribute revisions.
11 12 13 |
# File 'lib/file_history.rb', line 11 def revisions @revisions end |
Instance Method Details
#file_path(extension) ⇒ Object
17 18 19 |
# File 'lib/file_history.rb', line 17 def file_path(extension) "#{@provider}/#{@uuid}.#{extension}" end |
#load ⇒ Object
21 22 23 24 25 |
# File 'lib/file_history.rb', line 21 def load if File.exist? file_path('yml') @revisions = YAML.load(File.open(file_path('yml'), 'r:UTF-8', &:read)) end end |
#store ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/file_history.rb', line 27 def store if @revisions File.open(file_path('yml'), 'w:UTF-8') do |file| file.write(YAML::dump(@revisions)) end end end |