Class: Dropdown::OutputStores::FileStore

Inherits:
Object
  • Object
show all
Defined in:
lib/dropdown/output_stores/file_store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output_path) ⇒ FileStore

Returns a new instance of FileStore.



6
7
8
# File 'lib/dropdown/output_stores/file_store.rb', line 6

def initialize(output_path)
  @output_path = output_path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



4
5
6
# File 'lib/dropdown/output_stores/file_store.rb', line 4

def path
  @path
end

Instance Method Details

#save(contents, file_name) ⇒ Object



10
11
12
13
14
# File 'lib/dropdown/output_stores/file_store.rb', line 10

def save(contents, file_name)
  create_directory @output_path
  @path = "#{@output_path}/#{file_name}"
  File.open(@path, 'w+') { |f| f.write contents }
end