Module: KaveRestApi::StringHelper
- Included in:
- String
- Defined in:
- lib/kavenegar-ruby/helpers/convertor.rb,
lib/kavenegar-ruby/helpers/validator.rb
Instance Method Summary collapse
Instance Method Details
#ctpd ⇒ Object
16 17 18 |
# File 'lib/kavenegar-ruby/helpers/convertor.rb', line 16 def ctpd return self.to_s.tr('01123456789,','۰١۱۲۳۴۵۶۷۸۹،') end |
#ctsd ⇒ Object
12 13 14 |
# File 'lib/kavenegar-ruby/helpers/convertor.rb', line 12 def ctsd return self.to_s.tr('۰١۱۲۳۴۵۶۷۸۹،١٢٣٤٥٦٧٨٩٠','01123456789,1234567890') end |
#is_phone? ⇒ Boolean
17 18 19 |
# File 'lib/kavenegar-ruby/helpers/validator.rb', line 17 def is_phone? return !!self.ctsd.match(/^(09{1})+([1-3]{1})+(\d{8})$/) end |
#multibyte? ⇒ Boolean
13 14 15 |
# File 'lib/kavenegar-ruby/helpers/validator.rb', line 13 def multibyte? chars.count < bytes.count end |
#strip_emoji ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/kavenegar-ruby/helpers/convertor.rb', line 20 def strip_emoji str = self.force_encoding('utf-8').encode arr_regex=[/[\u{1f600}-\u{1f64f}]/,/[\u{2702}-\u{27b0}]/,/[\u{1f680}-\u{1f6ff}]/,/[\u{24C2}-\u{1F251}]/,/[\u{1f300}-\u{1f5ff}]/] arr_regex.each do |regex| str = str.gsub regex, '' end return str end |