Class: Acv2lrtemplate::Exporter
- Defined in:
- lib/acv2lrtemplate/exporter.rb
Constant Summary collapse
- TITLES =
%i(ToneCurvePV2012 ToneCurvePV2012Red ToneCurvePV2012Green ToneCurvePV2012Blue).freeze
Instance Attribute Summary collapse
-
#curves ⇒ Object
readonly
Returns the value of attribute curves.
-
#exported_file ⇒ Object
readonly
Returns the value of attribute exported_file.
-
#file_name ⇒ Object
readonly
Returns the value of attribute file_name.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #export! ⇒ Object
-
#initialize(curves, file_name, name = nil) ⇒ Exporter
constructor
TODO: add option to export to memory, not to a file.
Constructor Details
#initialize(curves, file_name, name = nil) ⇒ Exporter
TODO: add option to export to memory, not to a file
17 18 19 20 21 22 23 24 |
# File 'lib/acv2lrtemplate/exporter.rb', line 17 def initialize(curves, file_name, name = nil) raise Acv2lrtemplate::Errors::Exporter::CurvesDataInvalid unless !curves.blank? && curves.kind_of?(Array) @curves = curves raise Acv2lrtemplate::Errors::Exporter::NoFileProvided if file_name.blank? @file_name = file_name @name = name || sanitize_filename.titleize @exported_file = nil end |
Instance Attribute Details
#curves ⇒ Object (readonly)
Returns the value of attribute curves.
14 15 16 |
# File 'lib/acv2lrtemplate/exporter.rb', line 14 def curves @curves end |
#exported_file ⇒ Object (readonly)
Returns the value of attribute exported_file.
14 15 16 |
# File 'lib/acv2lrtemplate/exporter.rb', line 14 def exported_file @exported_file end |
#file_name ⇒ Object (readonly)
Returns the value of attribute file_name.
14 15 16 |
# File 'lib/acv2lrtemplate/exporter.rb', line 14 def file_name @file_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
14 15 16 |
# File 'lib/acv2lrtemplate/exporter.rb', line 14 def name @name end |
Instance Method Details
#export! ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/acv2lrtemplate/exporter.rb', line 26 def export! structure = generate_structure.to_json string = Acv2lrtemplate::JSON2lrtemplate.new(structure).convert! File.open(new_file_name, 'w') do |file| file.puts("--#{COPYRIGHT}") file.puts(string) end @exported_file = new_file_name new_file_name end |