Sha256: cac5c94af05a71a421ee9eb241ecc2a390704f6d257e3f83d9aeb6d5cb152dcd

Contents?: true

Size: 528 Bytes

Versions: 4

Compression:

Stored size: 528 Bytes

Contents

class Sheet::Write

  attr_accessor :name

  def initialize(name)
    @name = name
  end

  def write
    create_dir_if_doesnt_exist
    if editor_is_set?
      Sheet.exec("#{Sheet.editor} #{Sheet.sheet_path(name)}", true)
    else
      Sheet.write "Please set the $EDITOR variable to write files" 
    end
  end

  private

  def editor_is_set?
    (editor = Sheet.editor) && editor.length > 0
  end

  def create_dir_if_doesnt_exist
    if ! Dir.exists?(Sheet.sheets_dir)
      Dir.mkdir(Sheet.sheets_dir)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sheet-0.1.3 lib/sheet/write.rb
sheet-0.1.2 lib/sheet/write.rb
sheet-0.1.1 lib/sheet/write.rb
sheet-0.1.0 lib/sheet/write.rb