class Musedown::Score

Attributes

prebuilt[R]
relative_image_file[RW]
relative_score_file[RW]
score_file[RW]

Public Class Methods

new(prebuilt) click to toggle source
# File lib/musedown.rb, line 11
def initialize(prebuilt)
    @score_file = nil
    @relative_score_file = nil
    @relative_image_file = nil
    @prebuilt = prebuilt
end

Public Instance Methods

build(command) click to toggle source
# File lib/musedown.rb, line 18
def build(command)
    begin
        image_file = "#{@score_file.gsub(".mscz", "-mscz")}.png"
        result = `#{command} #{@score_file} -o #{image_file}`
    rescue Errno::ENOENT => error
        puts("⚠️ Error building #{@score_file}: #{error}")
    end

    if $?.success?
        if !prebuilt
            @relative_image_file = @relative_score_file.sub(/.*\K\.mscz/, "-mscz-1.png")
        end
    else
        puts("⚠️ Failed to convert #{@score_file}")
    end
    return $?.success?
end