Class: Snapit::Storage
- Inherits:
-
Object
- Object
- Snapit::Storage
- Defined in:
- lib/snapit/storage.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(root_path) ⇒ Storage
constructor
A new instance of Storage.
- #output_path ⇒ Object
- #script_name ⇒ Object
- #set_script_name!(name) ⇒ Object
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
#path ⇒ Object (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_path ⇒ Object
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_name ⇒ Object
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 |