Class: Snip::Command::Edit
- Inherits:
-
Object
- Object
- Snip::Command::Edit
- Includes:
- Snip
- Defined in:
- lib/snip/command/edit.rb
Constant Summary
Constants included from Snip
DEFAULT_DIR, INSTALL_DIR, VERSION
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(args, options = {}) ⇒ Edit
constructor
A new instance of Edit.
Methods included from Snip
init, initialized?, snippet_exists?
Constructor Details
#initialize(args, options = {}) ⇒ Edit
Returns a new instance of Edit.
9 10 11 12 |
# File 'lib/snip/command/edit.rb', line 9 def initialize(args, ={}) @args = Array(args) @options = end |
Instance Method Details
#execute ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/snip/command/edit.rb', line 14 def execute name = @args raise NotInitializedError unless Snip::initialized? raise SnippetNotFoundError unless Snip::snippet_exists?(name) file_path = File.join(Snip::INSTALL_DIR, name) if Snip::Util::Editor::open(file_path) puts "Snippet updated successfully" end end |