Class: Localeapp::SyncFile

Inherits:
Struct
  • Object
show all
Defined in:
lib/localeapp/sync_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



4
5
6
# File 'lib/localeapp/sync_file.rb', line 4

def path
  @path
end

Instance Method Details

#dataObject



19
20
21
# File 'lib/localeapp/sync_file.rb', line 19

def data
  @data ||= SyncData.default
end

#refreshObject



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