Class: Catori::XML

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

Instance Method Summary collapse

Constructor Details

#initialize(sFile) ⇒ XML

Returns a new instance of XML.



5
6
7
8
9
10
# File 'lib/catori/XML.rb', line 5

def initialize(sFile)
	file = File.new(sFile)
	@db = Catori::Db.conectar		
	@root = REXML::Document.new(file).root
	@archivos=[]
end

Instance Method Details

#actualizarObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/catori/XML.rb', line 24

def actualizar
	albums=[]
	i=0
	@archivos.each{|oInfo|
		Catori::Db.llenarArtista(oInfo)
		Catori::Db.llenarAlbum(oInfo)
		Catori::Db.llenarCancion(oInfo)
		id_album=oInfo.album.crearSha+oInfo.artist.crearSha
		if !oInfo.year.nil? and !albums.include?(id_album)
			Catori::Db.actualizarAlbumFecha(oInfo)
			albums.push(id_album)
		end
		Catori::Db.actualizarArchivo(oInfo)
		i+=1
	}
	i
end

#rastreaObject



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/catori/XML.rb', line 11

def rastrea
@root.elements.each("file") {|f|
	cd=f.attributes['cd']
	file_id=f.attributes['id']
	file_name=@db.select_one("select file_name from file WHERE file_id=? and cd_id=?",file_id,cd).to_s
	oInfo=AudioInfo::Virtual.new(cd,file_name)
	f.elements.each("*") {|e|
		oInfo.send(e.name+"=",e.text) if !e.text.nil?
	}
	
	@archivos.push(oInfo)
}
end