Class: Snaptoken::Representations::BaseRepresentation

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

Direct Known Subclasses

Git, Litdiff

Instance Method Summary collapse

Constructor Details

#initialize(tutorial) ⇒ BaseRepresentation

Returns a new instance of BaseRepresentation.



2
3
4
# File 'lib/snaptoken/representations/base_representation.rb', line 2

def initialize(tutorial)
  @tutorial = tutorial
end

Instance Method Details

#exists?Boolean

Returns true if this representation currently exists on disk.

Returns:

  • (Boolean)


27
28
29
# File 'lib/snaptoken/representations/base_representation.rb', line 27

def exists?
  !modified_at.nil?
end

#load!(options = {}) ⇒ Object

Should load @tutorial (in place) from disk, and return it.

Raises:

  • (NotImplementedError)


12
13
14
# File 'lib/snaptoken/representations/base_representation.rb', line 12

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)


18
19
20
21
22
23
24
# File 'lib/snaptoken/representations/base_representation.rb', line 18

def modified?
  synced_at = @tutorial.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!(options = {}) ⇒ Object

Should save @tutorial to disk.

Raises:

  • (NotImplementedError)


7
8
9
# File 'lib/snaptoken/representations/base_representation.rb', line 7

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