Class: AudioTag::ID3::V2::Frame

Inherits:
StreamSection show all
Defined in:
lib/audio_tag/id3/v2/frame.rb

Instance Attribute Summary collapse

Attributes inherited from StreamReader

#stream

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from StreamReader

#read, #read!, #read_byte, #read_byte!, #read_bytes, #read_bytes!, #read_bytes_until, #read_bytes_until!, #read_until, #read_until!

Constructor Details

#initialize(stream, header: FrameHeader.new(stream)) ⇒ Frame

Returns a new instance of Frame.



7
8
9
10
11
# File 'lib/audio_tag/id3/v2/frame.rb', line 7

def initialize(stream, header: FrameHeader.new(stream))
  @header = header

  super(stream)
end

Instance Attribute Details

#headerObject (readonly)

Returns the value of attribute header.



5
6
7
# File 'lib/audio_tag/id3/v2/frame.rb', line 5

def header
  @header
end

#raw_dataObject (readonly)

Returns the value of attribute raw_data.



5
6
7
# File 'lib/audio_tag/id3/v2/frame.rb', line 5

def raw_data
  @raw_data
end

Class Method Details

.build(stream) ⇒ Object



25
26
27
28
29
# File 'lib/audio_tag/id3/v2/frame.rb', line 25

def self.build(stream)
  header = FrameHeader.new(stream)

  header.frame_class.new(stream, header:)
end

Instance Method Details

#dataObject



17
18
19
# File 'lib/audio_tag/id3/v2/frame.rb', line 17

def data
  TextDecoder.decode(raw_data)
end

#keyObject



13
14
15
# File 'lib/audio_tag/id3/v2/frame.rb', line 13

def key
  header.key
end

#to_hObject



21
22
23
# File 'lib/audio_tag/id3/v2/frame.rb', line 21

def to_h
  { key => data }
end