class Quran::Surah

Public Instance Methods

ayahs() click to toggle source

@return [Array<Quran::Ayah>]

Returns an array of {Quran::Ayah} objects.
# File lib/quran/surah.rb, line 5
def ayahs
  grouped_paths.map do |index, paths|
    Quran::Ayah.new(index, paths, self)
  end.sort_by(&:index)
end

Private Instance Methods

grouped_paths() click to toggle source
# File lib/quran/surah.rb, line 13
def grouped_paths
  group_by = {}
  group_by.default_proc = proc { |h, k| h[k] = [] }
  Dir[File.join(path, "*.png")].each do |path|
    basename = File.basename(path, File.extname(path))
    _, ayah, _ = basename.split("_")
    group_by[Integer(ayah)].push(path)
  end
  group_by
end