Sha256: fd97de88c5322f8167fd34dd89a274fa78d7732b303d9e4864a9c0564b834e86
Contents?: true
Size: 1001 Bytes
Versions: 2
Compression:
Stored size: 1001 Bytes
Contents
# frozen_string_literal: true require 'yaml' require_relative 'song' require_relative 'render_song' module Songbook class GenerateSongFile attr_reader :input_path, :output_path, :verbose def initialize(input_path:, output_path:, verbose: false) @input_path = input_path @output_path = output_path @verbose = verbose end def call puts "Generating #{output_path}..." if verbose File.open(output_path, 'w') { |file| file.write(song_text) } end private def song_text @song_text ||= RenderSong.new(song).call end def song table_width = song_data['config']['table_width'] if song_data['config'] @song ||= Song.new( title: File.basename(input_path, '.yml'), details: song_data['details'], chords: song_data['chords'], lyrics: song_data['lyrics'], table_width: table_width ) end def song_data @song_data ||= YAML.load_file(input_path) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
songbook-0.5.0 | lib/songbook/generate_song_file.rb |
songbook-0.4.0 | lib/songbook/generate_song_file.rb |