Sha256: b4d6ccdc7a258dc3a49cd0247ce5c1d7413650d7f6c5d2b80be75ccf8a9e31e0

Contents?: true

Size: 1 KB

Versions: 3

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

module Quran::Audio
  ##
  # The {Quran::Audio::Command Quran::Audio::Command} class
  # is the superclass of all commands.
  class Command < Cmd
    require_relative "command/ls"
    require_relative "command/pull"
    include FileUtils

    def method_missing(m, *ary, &b)
      Ryo.property?(options, m) ? options[m] : super
    end

    def respond_to_missing?(m, p = false)
      Ryo.property?(options, m) || super
    end

    def respond_to?(m, p = false)
      Ryo.property?(options, m) || super
    end

    private

    def dir
      @dir ||= Ryo.from({
        localbase: File.join(Dir.home, ".local"),
        rootdir: File.realpath(File.join(__dir__, "..", "..", "..")),
        sharedir: Ryo.memo { File.join(localbase, "share", "quran-audio") },
        datadir: Ryo.memo { File.join(rootdir, "share", "quran-audio", "data") }
      })
    end

    def options
      @options ||= parse_options(argv)
    end

    def line
      @line ||= IO::Line.new($stdout)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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