module KaveRestApi::StringHelper
Public Instance Methods
ctpd()
click to toggle source
# File lib/kavenegar-ruby/helpers/convertor.rb, line 16 def ctpd return self.to_s.tr('01123456789,','۰١۱۲۳۴۵۶۷۸۹،') end
ctsd()
click to toggle source
# File lib/kavenegar-ruby/helpers/convertor.rb, line 12 def ctsd return self.to_s.tr('۰١۱۲۳۴۵۶۷۸۹،١٢٣٤٥٦٧٨٩٠','01123456789,1234567890') end
is_phone?()
click to toggle source
# 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?()
click to toggle source
# File lib/kavenegar-ruby/helpers/validator.rb, line 13 def multibyte? chars.count < bytes.count end
strip_emoji()
click to toggle source
# 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