Class: String

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

Instance Method Summary collapse

Instance Method Details

#numeric?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/ankusa/extensions.rb', line 4

def numeric?
  true if Float(self) rescue false
end

#to_asciiObject



8
9
10
11
12
# File 'lib/ankusa/extensions.rb', line 8

def to_ascii
  # from http://www.jroller.com/obie/tags/unicode
  converter = Iconv.new('ASCII//IGNORE//TRANSLIT', 'UTF-8') 
  converter.iconv(self).unpack('U*').select { |cp| cp < 127 }.pack('U*') rescue ""
end