Class: ID3Tag::AudioFile

Inherits:
Object
  • Object
show all
Defined in:
lib/id3tag/audio_file.rb

Constant Summary collapse

ID3V1_TAG_SIZE =
128
ID3V2_TAG_HEADER_SIZE =
10
IDV1_TAG_IDENTIFIER =
"TAG"
IDV2_TAG_IDENTIFIER =
"ID3"

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ AudioFile

Returns a new instance of AudioFile.



8
9
10
# File 'lib/id3tag/audio_file.rb', line 8

def initialize(file)
  @file = file
end

Instance Method Details

#v1_tag_bodyObject



22
23
24
25
# File 'lib/id3tag/audio_file.rb', line 22

def v1_tag_body
  @file.seek(-ID3V1_TAG_SIZE + IDV1_TAG_IDENTIFIER.size, IO::SEEK_END)
  @file.read
end

#v1_tag_present?Boolean

Returns:

  • (Boolean)


12
13
14
15
# File 'lib/id3tag/audio_file.rb', line 12

def v1_tag_present?
  @file.seek(-ID3V1_TAG_SIZE, IO::SEEK_END)
  @file.read(3) == IDV1_TAG_IDENTIFIER
end

#v2_tag_bodyObject



27
28
29
30
# File 'lib/id3tag/audio_file.rb', line 27

def v2_tag_body
  @file.seek(v2_tag_frame_and_padding_position)
  @file.read(v2_tag_frame_and_padding_size)
end

#v2_tag_major_version_numberObject



36
37
38
# File 'lib/id3tag/audio_file.rb', line 36

def v2_tag_major_version_number
  v2_tag_header.major_version_number
end

#v2_tag_minor_version_numberObject



40
41
42
# File 'lib/id3tag/audio_file.rb', line 40

def v2_tag_minor_version_number
  v2_tag_header.minor_version_number
end

#v2_tag_present?Boolean

Returns:

  • (Boolean)


17
18
19
20
# File 'lib/id3tag/audio_file.rb', line 17

def v2_tag_present?
  @file.rewind
  @file.read(3) == IDV2_TAG_IDENTIFIER
end

#v2_tag_versionObject



32
33
34
# File 'lib/id3tag/audio_file.rb', line 32

def v2_tag_version
  v2_tag_header.version_number
end