class Quran
Constants
- Title
Represents the title of a
Surah
- VERSION
Attributes
path[R]
Public Class Methods
new(path)
click to toggle source
@param [String] path
The path to The Qur'an.
# File lib/quran.rb, line 14 def initialize(path) @path = File.expand_path(path) end
Public Instance Methods
ayahs()
click to toggle source
@return [Array<Quran::Ayah]
Returns all ayahs from The Qur'an as an array of {Quran::Ayah} objects.
# File lib/quran.rb, line 40 def ayahs surahs.flat_map(&:ayahs) end
surahs()
click to toggle source
@return [Array<Quran::Surah>]
Returns an array of {Quran::Surah} objects.
# File lib/quran.rb, line 21 def surahs Dir[File.join(path, "*")].map do |path| desc_path = File.join(path, "DESCRIPTION.YML") next unless File.readable?(desc_path) desc = OpenStruct.new YAML.load_file(desc_path) Surah.new( Title.new(desc.title), desc.description, desc.index, path ) end.compact.sort_by(&:index) end