Class: Songbook::GenerateSongFile

Inherits:
Object
  • Object
show all
Defined in:
lib/songbook/generate_song_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input_path:, output_path:, verbose: false) ⇒ GenerateSongFile

Returns a new instance of GenerateSongFile.



11
12
13
14
15
# File 'lib/songbook/generate_song_file.rb', line 11

def initialize(input_path:, output_path:, verbose: false)
  @input_path = input_path
  @output_path = output_path
  @verbose = verbose
end

Instance Attribute Details

#input_pathObject (readonly)

Returns the value of attribute input_path.



9
10
11
# File 'lib/songbook/generate_song_file.rb', line 9

def input_path
  @input_path
end

#output_pathObject (readonly)

Returns the value of attribute output_path.



9
10
11
# File 'lib/songbook/generate_song_file.rb', line 9

def output_path
  @output_path
end

#verboseObject (readonly)

Returns the value of attribute verbose.



9
10
11
# File 'lib/songbook/generate_song_file.rb', line 9

def verbose
  @verbose
end

Instance Method Details

#callObject



17
18
19
20
21
# File 'lib/songbook/generate_song_file.rb', line 17

def call
  puts "Generating #{output_path}..." if verbose

  File.open(output_path, 'w') { |file| file.write(song_text) }
end