Class: AviGlitch::Avi::RiffChunk

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

Overview

RiffChunk represents a parsed RIFF chunk.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, size, value, list = false) ⇒ RiffChunk

Returns a new instance of RiffChunk.



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/aviglitch/avi.rb', line 17

def initialize id, size, value, list = false
  @binsize = size
  @is_list = list.kind_of? Array
  unless is_list?
    @id = id
    @value = value
  else
    @id = value
    @list = id
    @value = list
  end 
end

Instance Attribute Details

#binsizeObject

Returns the value of attribute binsize.



15
16
17
# File 'lib/aviglitch/avi.rb', line 15

def binsize
  @binsize
end

#idObject

Returns the value of attribute id.



15
16
17
# File 'lib/aviglitch/avi.rb', line 15

def id
  @id
end

#listObject

Returns the value of attribute list.



15
16
17
# File 'lib/aviglitch/avi.rb', line 15

def list
  @list
end

#valueObject

Returns the value of attribute value.



15
16
17
# File 'lib/aviglitch/avi.rb', line 15

def value
  @value
end

Instance Method Details

#child(id) ⇒ Object



44
45
46
# File 'lib/aviglitch/avi.rb', line 44

def child id
  children(id).first
end

#children(id) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/aviglitch/avi.rb', line 34

def children id
  if is_list?
    value.filter do |chk|
      chk.id == id
    end
  else
    []
  end
end

#inspectObject



62
63
64
65
66
67
68
69
70
# File 'lib/aviglitch/avi.rb', line 62

def inspect
  if @is_list
    "{list: \"#{list}\", id: \"#{id}\", binsize: #{binsize}, value: #{value}}"
  elsif !value.nil?
    "{id: \"#{id}\", binsize: #{binsize}, value: \"#{value}\"}"
  else 
    "{id: \"#{id}\", binsize: #{binsize}}"
  end
end

#is_list?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/aviglitch/avi.rb', line 30

def is_list?
  @is_list
end

#search(*args) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/aviglitch/avi.rb', line 48

def search *args
  a1 = args.shift
  r = value.filter { |v| 
    v.id == a1
  }.collect { |v|
    if args.size > 0
      v.search *args
    else
      v
    end
  }
  r.flatten
end