Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/uthmani_text_size.rb

Constant Summary collapse

UTHMANI_CHARS =
[
  "ب", "س", "م", "ٱ", "ل", "ه", "ر", "ح", "ن", "ي", "د", "ع", "ك", "و", "ا",
  "إ", "ت", "ص", "ط", "ق", "ذ", "أ", "غ", "ض", "ف", "ى", "ؤ", "ة", "ز", "خ",
  "ء", "ئ", "ش", "ظ", "ج", "ث"
].freeze

Instance Method Summary collapse

Instance Method Details

#uthmani_sizeObject

Counts the number of letters in a given Uthmani string

Example:

>> "ٱلرَّحْمَٰنِ".uthmani_size
=> 6


15
16
17
# File 'lib/uthmani_text_size.rb', line 15

def uthmani_size
  split('').select { |letter| UTHMANI_CHARS.include?(letter) }.size
end