Class: Localeapp::SyncFile
- Inherits:
-
Struct
- Object
- Struct
- Localeapp::SyncFile
- Defined in:
- lib/localeapp/sync_file.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path
4 5 6 |
# File 'lib/localeapp/sync_file.rb', line 4 def path @path end |
Instance Method Details
#data ⇒ Object
19 20 21 |
# File 'lib/localeapp/sync_file.rb', line 19 def data @data ||= SyncData.default end |
#refresh ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/localeapp/sync_file.rb', line 5 def refresh @data = if File.exist?(path) SyncData.from_hash( Localeapp.load_yaml_file(path) ) else SyncData.default end end |
#write(polled_at, updated_at) ⇒ Object
13 14 15 16 17 |
# File 'lib/localeapp/sync_file.rb', line 13 def write(polled_at, updated_at) data.polled_at = polled_at data.updated_at = updated_at File.open(path, 'w+') { |f| f.write(data.to_yaml) } end |