Class: Localeapp::SyncData

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#polled_atObject

Returns the value of attribute polled_at

Returns:

  • (Object)

    the current value of polled_at



24
25
26
# File 'lib/localeapp/sync_file.rb', line 24

def polled_at
  @polled_at
end

#updated_atObject

Returns the value of attribute updated_at

Returns:

  • (Object)

    the current value of updated_at



24
25
26
# File 'lib/localeapp/sync_file.rb', line 24

def updated_at
  @updated_at
end

Class Method Details

.defaultObject



25
26
27
# File 'lib/localeapp/sync_file.rb', line 25

def self.default
  new(0, 0)
end

.from_hash(hash) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/localeapp/sync_file.rb', line 29

def self.from_hash(hash)
  return default unless hash.is_a?(Hash)
  new(
    hash['polled_at']  || hash[:polled_at],
    hash['updated_at'] || hash[:updated_at]
  )
end

Instance Method Details

#to_hashObject



37
38
39
# File 'lib/localeapp/sync_file.rb', line 37

def to_hash
  {'polled_at' => polled_at.to_i, 'updated_at' => updated_at.to_i}
end

#to_yamlObject



41
42
43
# File 'lib/localeapp/sync_file.rb', line 41

def to_yaml
  to_hash.to_yaml
end