Class: QTRefMovie::QTBase

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

Instance Method Summary collapse

Constructor Details

#initializeQTBase

Returns a new instance of QTBase.



59
60
61
62
# File 'lib/qtrefmovie.rb', line 59

def initialize
  @list = []
  @type = '    '
end

Instance Method Details

#add_chunk(chunk, pos = -1 )) ⇒ Object



64
65
66
67
68
69
70
# File 'lib/qtrefmovie.rb', line 64

def add_chunk( chunk, pos = -1 )
  if pos < 0
    @list << chunk
  else
    @list[pos] = chunk
  end
end

#sizeObject



72
73
74
75
76
77
78
# File 'lib/qtrefmovie.rb', line 72

def size
  size = 0
  (0..(@list.count-1)).each do |i|
    size += @list[i].size
  end
  size += 2*4
end

#to_sObject



80
81
82
83
84
85
86
87
88
89
# File 'lib/qtrefmovie.rb', line 80

def to_s
  str = [size].pack('N')
  str += @type
  if @list.count > 0
    (0..(@list.count-1)).each do |i|
      str += @list[i].to_s
    end
  end
  str
end