Class: GistDirectory

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

Constant Summary collapse

MAJOR =
0
MINOR =
0
REVISION =
3
VERSION =
[MAJOR, MINOR, REVISION].map(&:to_s).join('.')

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path: nil) ⇒ GistDirectory

Returns a new instance of GistDirectory.



13
14
15
# File 'lib/gist_directory.rb', line 13

def initialize(path: nil)
  @path = File.expand_path(path)
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



10
11
12
# File 'lib/gist_directory.rb', line 10

def path
  @path
end

Instance Method Details

#create(filename: nil) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gist_directory.rb', line 17

def create(filename: nil)
  raise "No filename supplied" if filename.nil?

  if path_exists?
    fail_unless_gist_directory
    fail_if_filename_exists filename
    add_file_to_directory filename: filename
  else
    do_gist_create filename: filename
  end
end