Class: Songbook::GenerateSongFiles

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of GenerateSongFiles.



9
10
11
12
13
# File 'lib/songbook/generate_song_files.rb', line 9

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.



7
8
9
# File 'lib/songbook/generate_song_files.rb', line 7

def input_path
  @input_path
end

#output_pathObject (readonly)

Returns the value of attribute output_path.



7
8
9
# File 'lib/songbook/generate_song_files.rb', line 7

def output_path
  @output_path
end

#verboseObject (readonly)

Returns the value of attribute verbose.



7
8
9
# File 'lib/songbook/generate_song_files.rb', line 7

def verbose
  @verbose
end

Instance Method Details

#callObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/songbook/generate_song_files.rb', line 15

def call
  Dir.glob("#{input_path}/*.yml") do |filename|
    basename = File.basename(filename, '.yml')

    output_file = "#{output_path}/#{basename}.txt"

    service = GenerateSongFile.new(
      input_path: filename,
      output_path: output_file,
      verbose: verbose
    )

    service.call
  end
end