Class: BMFF::Box::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/bmff/box/base.rb

Overview

vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ioObject

Returns the value of attribute io.



5
6
7
# File 'lib/bmff/box/base.rb', line 5

def io
  @io
end

#largesizeObject

Returns the value of attribute largesize.



5
6
7
# File 'lib/bmff/box/base.rb', line 5

def largesize
  @largesize
end

#offsetObject

Returns the value of attribute offset.



5
6
7
# File 'lib/bmff/box/base.rb', line 5

def offset
  @offset
end

#parentObject

Returns the value of attribute parent.



5
6
7
# File 'lib/bmff/box/base.rb', line 5

def parent
  @parent
end

#sizeObject

Returns the value of attribute size.



5
6
7
# File 'lib/bmff/box/base.rb', line 5

def size
  @size
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/bmff/box/base.rb', line 5

def type
  @type
end

#usertypeObject

Returns the value of attribute usertype.



5
6
7
# File 'lib/bmff/box/base.rb', line 5

def usertype
  @usertype
end

Class Method Details

.register_box(*boxtypes) ⇒ Object



8
9
10
11
12
# File 'lib/bmff/box/base.rb', line 8

def self.register_box(*boxtypes)
  boxtypes.each do |boxtype|
    BMFF::Box::Map.register_box(boxtype, self)
  end
end

.register_uuid_box(uuid) ⇒ Object



14
15
16
# File 'lib/bmff/box/base.rb', line 14

def self.register_uuid_box(uuid)
  BMFF::Box::Map.register_uuid_box(uuid, self)
end

Instance Method Details

#actual_sizeObject



18
19
20
21
22
# File 'lib/bmff/box/base.rb', line 18

def actual_size
  return largesize if size == 1
  return nil if size == 0
  return size
end

#container?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/bmff/box/base.rb', line 61

def container?
  false
end

#eob?Boolean

end of box?

Returns:

  • (Boolean)


32
33
34
35
36
37
38
# File 'lib/bmff/box/base.rb', line 32

def eob?
  if actual_size
    return io.pos >= offset + actual_size
  else
    return io.eof?
  end
end

#parseObject



48
49
50
51
52
53
54
55
56
# File 'lib/bmff/box/base.rb', line 48

def parse
  parse_data
  if actual_size
    if io.pos > offset + actual_size
      raise RangeError, "Given box size is smaller than expected."
    end
  end
  seek_to_end
end

#parse_dataObject



58
59
# File 'lib/bmff/box/base.rb', line 58

def parse_data
end

#remaining_sizeObject



24
25
26
27
28
29
# File 'lib/bmff/box/base.rb', line 24

def remaining_size
  if actual_size
    return (offset + actual_size) - io.pos
  end
  nil
end

#rootObject



65
66
67
68
69
# File 'lib/bmff/box/base.rb', line 65

def root
  ancestor = parent
  ancestor = ancestor.parent while ancestor.respond_to?(:parent) && ancestor.parent
  ancestor
end

#seek_to_endObject



40
41
42
43
44
45
46
# File 'lib/bmff/box/base.rb', line 40

def seek_to_end
  if actual_size
    io.pos = offset + actual_size
  else
    io.seek(0, IO::SEEK_END)
  end
end