Class: Snapit::Storage

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root_path) ⇒ Storage

Returns a new instance of Storage.



8
9
10
11
# File 'lib/snapit/storage.rb', line 8

def initialize(root_path)
  @path = root_path.join("snapit_captures")
  FileUtils.mkdir_p(path) unless Dir.exists?(path)
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/snapit/storage.rb', line 6

def path
  @path
end

Instance Method Details

#output_pathObject



22
23
24
25
26
# File 'lib/snapit/storage.rb', line 22

def output_path
  p = path.join(script_name)
  FileUtils.mkdir_p(p) unless Dir.exists?(p)
  p
end

#script_nameObject



18
19
20
# File 'lib/snapit/storage.rb', line 18

def script_name
  @script_name || "default"
end

#set_script_name!(name) ⇒ Object



13
14
15
16
# File 'lib/snapit/storage.rb', line 13

def set_script_name!(name)
  @script_name = name
  @script_name = @script_name.gsub(/[^0-9a-z ]/i, '').gsub(/ /i, '_')
end