Class: Snaptoken::Representations::BaseRepresentation
- Inherits:
-
Object
- Object
- Snaptoken::Representations::BaseRepresentation
- Defined in:
- lib/snaptoken/representations/base_representation.rb
Instance Method Summary collapse
-
#exists? ⇒ Boolean
Returns true if this representation currently exists on disk.
-
#initialize(tutorial) ⇒ BaseRepresentation
constructor
A new instance of BaseRepresentation.
-
#load!(options = {}) ⇒ Object
Should load @tutorial (in place) from disk, and return it.
-
#modified? ⇒ Boolean
Returns true if this representation has been modified by the user since the last sync.
-
#save!(options = {}) ⇒ Object
Should save @tutorial to disk.
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.
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.
12 13 14 |
# File 'lib/snaptoken/representations/base_representation.rb', line 12 def load!( = {}) raise NotImplementedError end |
#modified? ⇒ Boolean
Returns true if this representation has been modified by the user since the last sync.
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.
7 8 9 |
# File 'lib/snaptoken/representations/base_representation.rb', line 7 def save!( = {}) raise NotImplementedError end |