Class: Agave::Dump::Operation::CreateDataFile

Inherits:
Object
  • Object
show all
Defined in:
lib/agave/dump/operation/create_data_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, path, format, value) ⇒ CreateDataFile

Returns a new instance of CreateDataFile.



11
12
13
14
15
16
# File 'lib/agave/dump/operation/create_data_file.rb', line 11

def initialize(context, path, format, value)
  @context = context
  @path = path
  @format = format
  @value = value
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



9
10
11
# File 'lib/agave/dump/operation/create_data_file.rb', line 9

def context
  @context
end

#formatObject (readonly)

Returns the value of attribute format.



9
10
11
# File 'lib/agave/dump/operation/create_data_file.rb', line 9

def format
  @format
end

#pathObject (readonly)

Returns the value of attribute path.



9
10
11
# File 'lib/agave/dump/operation/create_data_file.rb', line 9

def path
  @path
end

#valueObject (readonly)

Returns the value of attribute value.



9
10
11
# File 'lib/agave/dump/operation/create_data_file.rb', line 9

def value
  @value
end

Instance Method Details

#performObject



18
19
20
21
22
23
24
# File 'lib/agave/dump/operation/create_data_file.rb', line 18

def perform
  FileUtils.mkdir_p(File.dirname(path))

  File.open(File.join(context.path, path), 'w') do |file|
    file.write Format.dump(format, value)
  end
end