class Leg::Representations::BaseRepresentation

Public Class Methods

new(config) click to toggle source
# File lib/leg/representations/base_representation.rb, line 4
def initialize(config)
  @config = config
end

Public Instance Methods

exists?() click to toggle source

Returns true if this representation currently exists on disk.

# File lib/leg/representations/base_representation.rb, line 29
def exists?
  !modified_at.nil?
end
load!(options = {}) click to toggle source

Should load tutorial from disk, and return it.

# File lib/leg/representations/base_representation.rb, line 14
def load!(options = {})
  raise NotImplementedError
end
modified?() click to toggle source

Returns true if this representation has been modified by the user since the last sync.

# File lib/leg/representations/base_representation.rb, line 20
def modified?
  synced_at = @config.last_synced_at
  repr_modified_at = modified_at
  return false if synced_at.nil? or repr_modified_at.nil?

  repr_modified_at > synced_at
end
save!(tutorial, options = {}) click to toggle source

Should save tutorial to disk.

# File lib/leg/representations/base_representation.rb, line 9
def save!(tutorial, options = {})
  raise NotImplementedError
end

Private Instance Methods

modified_at() click to toggle source

Should return the Time the representation on disk was last modified, or nil if the representation doesn't exist.

# File lib/leg/representations/base_representation.rb, line 37
def modified_at
  raise NotImplementedError
end