class Songbook::GenerateSongFile

Attributes

input_path[R]
output_path[R]
verbose[R]

Public Class Methods

new(input_path:, output_path:, verbose: false) click to toggle source
# 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

Public Instance Methods

call() click to toggle source
# 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

Private Instance Methods

song() click to toggle source
# File lib/songbook/generate_song_file.rb, line 29
def song
  @song ||= Song.new(
    title: File.basename(input_path, '.yml'),
    details: song_data['details'],
    chords: song_data['chords'],
    lyrics: song_data['lyrics']
  )
end
song_data() click to toggle source
# File lib/songbook/generate_song_file.rb, line 38
def song_data
  @song_data ||= YAML.load_file(input_path)
end
song_text() click to toggle source
# File lib/songbook/generate_song_file.rb, line 25
def song_text
  @song_text ||= RenderSong.new(song).call
end