Class: Leg::Representations::BaseRepresentation

Inherits:
Object
  • Object
show all
Defined in:
lib/leg/representations/base_representation.rb

Direct Known Subclasses

Git, Litdiff

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ BaseRepresentation

Returns a new instance of BaseRepresentation.



4
5
6
# File 'lib/leg/representations/base_representation.rb', line 4

def initialize(config)
  @config = config
end

Instance Method Details

#exists?Boolean

Returns true if this representation currently exists on disk.

Returns:

  • (Boolean)


29
30
31
# File 'lib/leg/representations/base_representation.rb', line 29

def exists?
  !modified_at.nil?
end

#load!(options = {}) ⇒ Object

Should load tutorial from disk, and return it.

Raises:

  • (NotImplementedError)


14
15
16
# File 'lib/leg/representations/base_representation.rb', line 14

def load!(options = {})
  raise NotImplementedError
end

#modified?Boolean

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

Returns:

  • (Boolean)


20
21
22
23
24
25
26
# 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 = {}) ⇒ Object

Should save tutorial to disk.

Raises:

  • (NotImplementedError)


9
10
11
# File 'lib/leg/representations/base_representation.rb', line 9

def save!(tutorial, options = {})
  raise NotImplementedError
end