Module: Cline::Serializable::Dir
- Included in:
- Config, Data, Cline::Session, Cline::Skill, Task, Workspace
- Defined in:
- lib/cline/serializable/dir.rb
Overview
Add features to initialize from and save an object to a directory.
Provides:
.open(dir) -> [Object, nil]Provides a new instance initialized from the directory, or nil if no directory.#dir -> [String]The directory from which this object was initialized.#subpath(path) -> [String]Provide a sub-path from the directory the object was initialized from.
Defined Under Namespace
Modules: ClassMethods
Internal collapse
-
#create ⇒ Boolean
readonly
Should data be created if it does not exist?.
-
#dir ⇒ String
readonly
The directory used for the object's initialization.
Internal collapse
-
.included(base) ⇒ Object
Hook used when this mixin is included in a base class.
-
#initialize_from_dir(dir, create:) ⇒ Object
Initialize this instance from a directory.
-
#subpath(path) ⇒ String
Return the path to a sub-path of our instance directory.
Instance Attribute Details
#create ⇒ Boolean (readonly)
Returns Should data be created if it does not exist?.
61 62 63 |
# File 'lib/cline/serializable/dir.rb', line 61 def create @create end |
#dir ⇒ String (readonly)
Returns The directory used for the object's initialization.
58 59 60 |
# File 'lib/cline/serializable/dir.rb', line 58 def dir @dir end |
Class Method Details
.included(base) ⇒ Object
Hook used when this mixin is included in a base class
53 54 55 |
# File 'lib/cline/serializable/dir.rb', line 53 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#initialize_from_dir(dir, create:) ⇒ Object
Initialize this instance from a directory
67 68 69 70 |
# File 'lib/cline/serializable/dir.rb', line 67 def initialize_from_dir(dir, create:) @dir = dir @create = create end |
#subpath(path) ⇒ String
Return the path to a sub-path of our instance directory
76 77 78 |
# File 'lib/cline/serializable/dir.rb', line 76 def subpath(path) ::File.join(dir, path) end |