Module: Wahy

Defined in:
lib/wahy.rb,
lib/wahy/version.rb

Defined Under Namespace

Modules: Opt_PARSER Classes: Parser

Constant Summary collapse

XML_DATA =
Wahy::Parser.load_xml
ENGLISH =
XML_DATA[:en]
TUR =
XML_DATA[:tr]
SURELER =
{
	:tur => ["Fatiha", "Bakara", "Ali İmran", "Nisa", "Maide", "Enam", "Araf", "Enfal", "Tevbe", "Yunus", "Hud", "Yusuf", "Rad", "İbrahim", "Hicr", "Nahl", "Isra", "Kehf", "Meryem", "Taha", "Enbiya", "Hac", "Muminun", "Nur", "Furkan", "Suara", "Neml", "Kasas", "Ankebut", "Rum", "Lukman", "Secde", "Ahzab", "Sebe", "Fatir", "Yasin", "Saffat", "Sad", "Zümer", "Mumin", "Fussilet", "Sura", "Zuhruf", "Duhan", "Casiye", "Ahkaf", "Muhammed", "Fetih", "Hucurat", "Kaf", "Zariyat", "Tur", "Necm", "Kamer", "Rahman", "Vakia", "Hadid", "Mücadele", "Hasr", "Mümtahine", "Saf", "Cuma", "Münafikun", "Tegabun", "Talak", "Tahrim", "Mülk", "Kalem", "Hakka", "Mearic", "Nuh", "Cin", "Müzzemmil", "Müddessir", "Kıyamet", "İnsan", "Murselat", "Nebe", "Naziat", "Abese", "Tekvir", "İnfitar", "Mutaffifin", "İnsikak", "Buruc", "Tarik", "Ala", "Gasiye", "Fecr", "Beled", "Şems", "Leyl", "Duha", "İnşirah", "Tin", "Alak", "Kadir", "Beyyine", "Zilzal", "Adiyat", "Karia", "Tekasür", "Asr", "Hümeze", "Fil", "Kureyş", "Maun", "Kevser", "Kafirun", "Nasr", "Leheb", "İhlas", "Felak", "Nas"],
	:eng => ["The Opening", "The Cow", "The Family Of Imran", "Women", "The Food", "The Cattle", "The Elevated Place", "The Spoils Of War", "Repentance", "Yunus", "Hud", "Yusuf", "The Thunder", "Ibrahim", "The Rock", "The Bee", "The Israelites", "The Cave", "Marium", "Ta Ha", "The Prophets", "The Pilgrimage", "The Believers", "The Light", "The Criterion", "The Poets", "The Ant", "The Narrative", "The Spider", "The Romans", "Luqman", "The Adoration", "The Allies", "Saba", "The Originator", "Ya Seen", "The Rangers", "Suad", "The Companies", "The Believer", "Ha Mim", "The Counsel", "The Embellishment", "The Evident Smoke", "The Kneeling", "The Sandhills", "Muhammad", "The Victory", "The Chambers", "Qaf", "The Scatterers", "The Mountain", "The Star", "The Moon", "The Beneficient", "The Great Event", "The Iron", "The Pleading One", "The Banishment", "The Examined One", "The Ranks", "Friday", "The Hypocrites", "Loss And Gain", "The Divorce", "The Prohibition", "The Kingdom", "The Pen", "The Sure Calamity", "The Ways Of Ascent", "Nuh", "The Jinn", "The Wrapped Up", "The Clothe Done", "The Resurrection", "The Man", "The Emissaries", "The Great Event", "Those Who Pull Out", "He Frowned", "The Covering Up", "The Cleaving Asund", "The Defrauders", "The Bursting Asund", "The Mansions Of The Stars", "The Night-Comer", "The Most High", "The Overwhelming", "The Daybreak", "The City", "The Sun", "The Night", "The Early Hours", "The Expansion", "The Fig", "The Clot", "The Majesty", "The Clear Evidence", "The Shaking", "The Assaulters", "The Terrible Calam", "The Multiplicatio", "Time", "The Slanderer", "The Elephant", "The Qureaish", "The Daily Necessar", "The Heavenly Fount", "The Unbelievers", "The Help", "The Flame", "The Unity", "The Dawn", "The Men"]
}
OPTIONS =
Opt_PARSER.opsiyonlar args
LANG =
SCRIPTURE =
OPTIONS[:scripture] || 0
SIGN =
OPTIONS[:sign] || 'all'
Doc =
Nokogiri::XML(LANG == 'tur' ? TUR : ENGLISH) do |config|
  config.strict.noblanks
end
Elements =
Doc.xpath("//*[@ChapterName]")
VERSION =
"1.3.9"

Class Method Summary collapse

Class Method Details

.chapters_data(parsed_xml_data) ⇒ Object



118
119
120
121
# File 'lib/wahy.rb', line 118

def self.chapters_data parsed_xml_data
	elements = parsed_xml_data.xpath("//*[@ChapterName]")
	elements
end

.new_data(lang) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/wahy.rb', line 105

def self.new_data lang
	if lang == 'tur'
doc = Nokogiri::XML(TUR)
	elsif lang == 'eng'
doc = Nokogiri::XML(ENGLISH)
	else
print 'Please, select a correct option ("tur" or "eng"): '
selection = gets.chomp
new_data selection
	end
	doc
end

.scripture_data(parsed_chapter_data, scripture_name) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/wahy.rb', line 123

def self.scripture_data parsed_chapter_data, scripture_name
	s_data = nil
	if scripture_name =~ /[[:digit:]]/
s_data = parsed_chapter_data[scripture_name]
	else
sc = scripture_name.include?(" ") ? scripture_name.split(" ").map {|i| i = i.capitalize}.join(" ") : scripture_name.capitalize
SURELER.values.each do |v|
	s_data = v.index(sc) if v.include? sc
end
	end
	scripture = parsed_chapter_data[(s_data || 0)]
	scripture
end

.show_wahyObject



92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/wahy.rb', line 92

def self.show_wahy
  var = Elements[SCRIPTURE]
  puts var.attr('ChapterName').upcase.center(40, "*")

  if SIGN == 'all'
    var.css('Verse').each_with_index do |v, i|
      print "[#{i + 1}]: ".red, "#{v.text}".green, "\n"
    end
  else
    print "[#{SIGN + 1}]: ".red, "#{var.css('Verse')[SIGN].text}".green, "\n"
  end
end

.sign_data(scripture_data) ⇒ Object



137
138
139
140
141
142
143
# File 'lib/wahy.rb', line 137

def self.sign_data scripture_data
	sign = []
	scripture_data.css('Verse').each do |v|
sign << v.text
	end
	sign
end

.sign_data_object(scripture_data) ⇒ Object



145
146
147
# File 'lib/wahy.rb', line 145

def self.sign_data_object scripture_data
	scripture_data.css('Verse')
end

.specific_sign_object(scripture_data, sign_number) ⇒ Object



154
155
156
# File 'lib/wahy.rb', line 154

def self.specific_sign_object scripture_data, sign_number
	sign = scripture_data.css('Verse')[sign_number]
end

.take_specific_sign(sign_data, sign_number) ⇒ Object



149
150
151
152
# File 'lib/wahy.rb', line 149

def self.take_specific_sign sign_data, sign_number
	sign = sign_data[sign_number]
	sign
end