Skip to content

Instantly share code, notes, and snippets.

@theHamdiz
Last active February 20, 2018 06:53
Show Gist options
  • Save theHamdiz/8775d140c2996094034b8f7ea863b95e to your computer and use it in GitHub Desktop.
Save theHamdiz/8775d140c2996094034b8f7ea863b95e to your computer and use it in GitHub Desktop.
كود روبي بسيط يقوم باقتراح وفتح صفحه من القرآن عشوائيه لك لقرائتها. #Ruby script to suggest a page from the #Quran to read and open it. This base script could be further twisted to select a random #book for you to read and actually open it for you. or any other paged book that you have its pages available in your hard drive or on the internet.
class Quran
def initialize
# could be ARGV OR Any other path you prefer
@path = '/Users/a7madx7/Downloads/المصحف\ الجوامعي'
end
private
def suggest
# related to the quran could be changed
Random.rand(627) + 4
end
def file_from_number
case suggest.to_s.length
when 1
"000#{suggest}.jpg"
when 2
"00#{suggest}.jpg"
when 3
"0#{suggest}.jpg"
else
"#{suggest}.jpg"
end
end
public
def open_suggestion
`open #{@path}/#{file_from_number}`
end
end
Quran.new.open_suggestion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment