Class: Sheet::Write

Inherits:
Object
  • Object
show all
Defined in:
lib/sheet/write.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil) ⇒ Write

Returns a new instance of Write.



5
6
7
# File 'lib/sheet/write.rb', line 5

def initialize(name=nil)
  @name = name
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/sheet/write.rb', line 3

def name
  @name
end

Instance Method Details

#writeObject



9
10
11
12
13
14
15
16
17
# File 'lib/sheet/write.rb', line 9

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