Class: TagLib::File

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

Instance Method Summary collapse

Constructor Details

#initialize(p) ⇒ File

Returns a new instance of File.



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/taglib.rb', line 83

def initialize(p)
	@path = p
	if not @path
		raise BadPath.new
	end

	mahoro = Mahoro.new
	mahoro.flags = Mahoro::NONE
	mime = mahoro.file(@path)
	type = taglibForMime(mime)

	if type
		@file = TagLib.taglib_file_new_type(@path, type)
	else
		@file = TagLib.taglib_file_new(@path)
	end

	if not @file
		@path = nil
		raise BadFile.new
	end
end

Instance Method Details

#albumObject



136
137
138
# File 'lib/taglib.rb', line 136

def album
	return TagLib.taglib_tag_album(tag)
end

#album=(string) ⇒ Object



140
141
142
# File 'lib/taglib.rb', line 140

def album=(string)
	TagLib.taglib_tag_set_album(tag, string)
end

#artistObject



128
129
130
# File 'lib/taglib.rb', line 128

def artist
	return TagLib.taglib_tag_artist(tag)
end

#artist=(string) ⇒ Object



132
133
134
# File 'lib/taglib.rb', line 132

def artist=(string)
	TagLib.taglib_tag_set_artist(tag, string)
end

#bitrateObject



180
181
182
# File 'lib/taglib.rb', line 180

def bitrate
	return TagLib.taglib_audioproperties_bitrate(audio)
end

#channelsObject



188
189
190
# File 'lib/taglib.rb', line 188

def channels
	return TagLib.taglib_audioproperties_channels(audio)
end

#closeObject



110
111
112
113
114
115
116
117
118
# File 'lib/taglib.rb', line 110

def close
	if @file
		TagLib.taglib_file_free(@file)
	end
	@path = nil
	@file = nil
	@tag = nil
	@audio = nil
end

#commentObject



144
145
146
# File 'lib/taglib.rb', line 144

def comment
	return TagLib.taglib_tag_comment(tag)
end

#comment=(string) ⇒ Object



148
149
150
# File 'lib/taglib.rb', line 148

def comment=(string)
	TagLib.taglib_tag_set_comment(tag, string)
end

#genreObject



152
153
154
# File 'lib/taglib.rb', line 152

def genre
	return TagLib.taglib_tag_genre(tag)
end

#genre=(string) ⇒ Object



156
157
158
# File 'lib/taglib.rb', line 156

def genre=(string)
	TagLib.taglib_tag_set_genre(tag, string)
end

#lengthObject



176
177
178
# File 'lib/taglib.rb', line 176

def length
	return TagLib.taglib_audioproperties_length(audio)
end

#samplerateObject



184
185
186
# File 'lib/taglib.rb', line 184

def samplerate
	return TagLib.taglib_audioproperties_samplerate(audio)
end

#saveObject



106
107
108
# File 'lib/taglib.rb', line 106

def save
	TagLib.taglib_file_save(@file)
end

#titleObject



120
121
122
# File 'lib/taglib.rb', line 120

def title
	return TagLib.taglib_tag_title(tag)
end

#title=(string) ⇒ Object



124
125
126
# File 'lib/taglib.rb', line 124

def title=(string)
	TagLib.taglib_tag_set_title(tag, string)
end

#trackObject



168
169
170
# File 'lib/taglib.rb', line 168

def track
	return TagLib.taglib_tag_track(tag)
end

#track=(uint) ⇒ Object



172
173
174
# File 'lib/taglib.rb', line 172

def track=(uint)
	TagLib.taglib_tag_set_track(tag, uint)
end

#yearObject



160
161
162
# File 'lib/taglib.rb', line 160

def year
	return TagLib.taglib_tag_year(tag)
end

#year=(uint) ⇒ Object



164
165
166
# File 'lib/taglib.rb', line 164

def year=(uint)
	TagLib.taglib_tag_set_year(tag, uint)
end