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