Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/audioinfo.rb,
lib/catori/Db.rb

Instance Method Summary collapse

Instance Method Details

#crearShaObject



4
5
6
# File 'lib/catori/Db.rb', line 4

def crearSha()
  Digest::SHA1.hexdigest(self.downcase.gsub(/\W/,""))[0,32]
end

#encodingObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/audioinfo.rb', line 22

def encoding
cuenta=0
ascii=true
self.each_byte{|byte|
  if cuenta>0
    if (byte >> 6) != 0b10
      return "iso8859"
    else
      cuenta-=1
    end
  else
    next if(byte<128)
    ascii=false
    if (byte >> 5) == 0b110 
      cuenta=1
    elsif (byte >> 4) == 0b1110
      cuenta=2
    elsif (byte >> 3) == 0b11110
      cuenta=3
    else
      return "iso8859"
    end
  end
}
ascii ? "ascii":"utf8"
end

#to_utf8Object



48
49
50
# File 'lib/audioinfo.rb', line 48

def to_utf8
  (self.encoding=='iso8859') ? Iconv.new("utf-8","iso-8859-1").iconv(self.to_s) : self
end