Class: Mp3file::MP3File
- Inherits:
-
Object
- Object
- Mp3file::MP3File
- Defined in:
- lib/mp3file/mp3_file.rb
Instance Attribute Summary collapse
-
#audio_size ⇒ Object
readonly
Returns the value of attribute audio_size.
-
#bitrate ⇒ Object
readonly
Returns the value of attribute bitrate.
-
#extra_id3v2_tags ⇒ Object
Returns the value of attribute extra_id3v2_tags.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#file_size ⇒ Object
readonly
Returns the value of attribute file_size.
-
#first_header ⇒ Object
readonly
Returns the value of attribute first_header.
-
#first_header_offset ⇒ Object
readonly
Returns the value of attribute first_header_offset.
-
#id3v1_tag ⇒ Object
Returns the value of attribute id3v1_tag.
-
#id3v2_tag ⇒ Object
Returns the value of attribute id3v2_tag.
-
#layer ⇒ Object
readonly
Returns the value of attribute layer.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#mpeg_version ⇒ Object
readonly
Returns the value of attribute mpeg_version.
-
#num_frames ⇒ Object
readonly
Returns the value of attribute num_frames.
-
#samplerate ⇒ Object
readonly
Returns the value of attribute samplerate.
-
#total_samples ⇒ Object
readonly
Returns the value of attribute total_samples.
-
#vbri_header ⇒ Object
readonly
Returns the value of attribute vbri_header.
-
#vbri_header_offset ⇒ Object
readonly
Returns the value of attribute vbri_header_offset.
-
#xing_header ⇒ Object
readonly
Returns the value of attribute xing_header.
-
#xing_header_offset ⇒ Object
readonly
Returns the value of attribute xing_header_offset.
Instance Method Summary collapse
- #album ⇒ Object
- #artist ⇒ Object
- #comment ⇒ Object
- #each_header ⇒ Object
- #genre ⇒ Object
- #id3v1tag? ⇒ Boolean
- #id3v2tag? ⇒ Boolean
-
#initialize(file_path, options = {}) ⇒ MP3File
constructor
A new instance of MP3File.
- #title ⇒ Object
- #track ⇒ Object
- #vbr? ⇒ Boolean
- #year ⇒ Object
Constructor Details
#initialize(file_path, options = {}) ⇒ MP3File
Returns a new instance of MP3File.
14 15 16 17 |
# File 'lib/mp3file/mp3_file.rb', line 14 def initialize(file_path, = {}) file_path = Pathname.new(file_path). if file_path.is_a?(String) load_file(file_path, ) end |
Instance Attribute Details
#audio_size ⇒ Object (readonly)
Returns the value of attribute audio_size.
5 6 7 |
# File 'lib/mp3file/mp3_file.rb', line 5 def audio_size @audio_size end |
#bitrate ⇒ Object (readonly)
Returns the value of attribute bitrate.
9 10 11 |
# File 'lib/mp3file/mp3_file.rb', line 9 def bitrate @bitrate end |
#extra_id3v2_tags ⇒ Object
Returns the value of attribute extra_id3v2_tags.
12 13 14 |
# File 'lib/mp3file/mp3_file.rb', line 12 def @extra_id3v2_tags end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
5 6 7 |
# File 'lib/mp3file/mp3_file.rb', line 5 def file @file end |
#file_size ⇒ Object (readonly)
Returns the value of attribute file_size.
5 6 7 |
# File 'lib/mp3file/mp3_file.rb', line 5 def file_size @file_size end |
#first_header ⇒ Object (readonly)
Returns the value of attribute first_header.
6 7 8 |
# File 'lib/mp3file/mp3_file.rb', line 6 def first_header @first_header end |
#first_header_offset ⇒ Object (readonly)
Returns the value of attribute first_header_offset.
6 7 8 |
# File 'lib/mp3file/mp3_file.rb', line 6 def first_header_offset @first_header_offset end |
#id3v1_tag ⇒ Object
Returns the value of attribute id3v1_tag.
12 13 14 |
# File 'lib/mp3file/mp3_file.rb', line 12 def id3v1_tag @id3v1_tag end |
#id3v2_tag ⇒ Object
Returns the value of attribute id3v2_tag.
12 13 14 |
# File 'lib/mp3file/mp3_file.rb', line 12 def id3v2_tag @id3v2_tag end |
#layer ⇒ Object (readonly)
Returns the value of attribute layer.
9 10 11 |
# File 'lib/mp3file/mp3_file.rb', line 9 def layer @layer end |
#length ⇒ Object (readonly)
Returns the value of attribute length.
10 11 12 |
# File 'lib/mp3file/mp3_file.rb', line 10 def length @length end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
9 10 11 |
# File 'lib/mp3file/mp3_file.rb', line 9 def mode @mode end |
#mpeg_version ⇒ Object (readonly)
Returns the value of attribute mpeg_version.
9 10 11 |
# File 'lib/mp3file/mp3_file.rb', line 9 def mpeg_version @mpeg_version end |
#num_frames ⇒ Object (readonly)
Returns the value of attribute num_frames.
10 11 12 |
# File 'lib/mp3file/mp3_file.rb', line 10 def num_frames @num_frames end |
#samplerate ⇒ Object (readonly)
Returns the value of attribute samplerate.
9 10 11 |
# File 'lib/mp3file/mp3_file.rb', line 9 def samplerate @samplerate end |
#total_samples ⇒ Object (readonly)
Returns the value of attribute total_samples.
10 11 12 |
# File 'lib/mp3file/mp3_file.rb', line 10 def total_samples @total_samples end |
#vbri_header ⇒ Object (readonly)
Returns the value of attribute vbri_header.
8 9 10 |
# File 'lib/mp3file/mp3_file.rb', line 8 def vbri_header @vbri_header end |
#vbri_header_offset ⇒ Object (readonly)
Returns the value of attribute vbri_header_offset.
8 9 10 |
# File 'lib/mp3file/mp3_file.rb', line 8 def vbri_header_offset @vbri_header_offset end |
#xing_header ⇒ Object (readonly)
Returns the value of attribute xing_header.
7 8 9 |
# File 'lib/mp3file/mp3_file.rb', line 7 def xing_header @xing_header end |
#xing_header_offset ⇒ Object (readonly)
Returns the value of attribute xing_header_offset.
7 8 9 |
# File 'lib/mp3file/mp3_file.rb', line 7 def xing_header_offset @xing_header_offset end |
Instance Method Details
#album ⇒ Object
39 40 41 |
# File 'lib/mp3file/mp3_file.rb', line 39 def album (:album) end |
#artist ⇒ Object
35 36 37 |
# File 'lib/mp3file/mp3_file.rb', line 35 def artist (:artist) end |
#comment ⇒ Object
51 52 53 |
# File 'lib/mp3file/mp3_file.rb', line 51 def comment (:comment) end |
#each_header ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/mp3file/mp3_file.rb', line 59 def each_header file = File.open(@file.path, "rb") offset = @first_header_offset file.seek(offset, IO::SEEK_SET) while !file.eof? header = MP3Header.new(file) yield offset, header offset = offset + header.frame_size file.seek(offset, IO::SEEK_SET) end file.close end |
#genre ⇒ Object
55 56 57 |
# File 'lib/mp3file/mp3_file.rb', line 55 def genre (:genre) end |
#id3v1tag? ⇒ Boolean
23 24 25 |
# File 'lib/mp3file/mp3_file.rb', line 23 def id3v1tag? !@id3v1_tag.nil? end |
#id3v2tag? ⇒ Boolean
27 28 29 |
# File 'lib/mp3file/mp3_file.rb', line 27 def id3v2tag? !@id3v2_tag.nil? end |
#title ⇒ Object
31 32 33 |
# File 'lib/mp3file/mp3_file.rb', line 31 def title (:title) end |
#track ⇒ Object
43 44 45 |
# File 'lib/mp3file/mp3_file.rb', line 43 def track (:track) end |
#vbr? ⇒ Boolean
19 20 21 |
# File 'lib/mp3file/mp3_file.rb', line 19 def vbr? @vbr end |
#year ⇒ Object
47 48 49 |
# File 'lib/mp3file/mp3_file.rb', line 47 def year (:year) end |