Sha256: d5cc630bb52595809b28fca30bf4b50239c8b46c0cbf82c3efd8a09354c317ed

Contents?: true

Size: 630 Bytes

Versions: 2

Compression:

Stored size: 630 Bytes

Contents

# frozen_string_literal: true

module Quran::Audio
  class Command::Ls < Command
    set_banner usage: "quran-audio ls [OPTIONS]",
               description: "List recitations"

    def run
      recitations = Ryo.from_json(path: File.join(dir.datadir, "recitations.json"))
      template = File.binread(File.join(dir.datadir, "erb", "recitation.erb"))
      render(recitations, template)
    end

    private

    def render(recitations, template)
      puts Ryo.each(recitations).map { |switch, recitation|
        ERB.new(template).result_with_hash({switch:, recitation: Ryo(recitation)})
      }.join("\n")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
quran-audio-0.3.3 lib/quran/audio/command/ls.rb
quran-audio-0.3.2 lib/quran/audio/command/ls.rb