Class: Zippo::BinaryStructure::StructureMember

Inherits:
Object
  • Object
show all
Defined in:
lib/zippo/binary_structure/structure_member.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, pack, options = {}) ⇒ StructureMember

Returns a new instance of StructureMember.



4
5
6
7
8
9
# File 'lib/zippo/binary_structure/structure_member.rb', line 4

def initialize(name, pack, options = {})
  @name = name
  @pack = pack
  @options = options
  @width = StructureMember.width(@pack)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



24
25
26
# File 'lib/zippo/binary_structure/structure_member.rb', line 24

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



24
25
26
# File 'lib/zippo/binary_structure/structure_member.rb', line 24

def options
  @options
end

#packObject (readonly)

Returns the value of attribute pack.



24
25
26
# File 'lib/zippo/binary_structure/structure_member.rb', line 24

def pack
  @pack
end

#widthObject (readonly)

XXX unspec



15
16
17
# File 'lib/zippo/binary_structure/structure_member.rb', line 15

def width
  @width
end

Class Method Details

.width(pack) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/zippo/binary_structure/structure_member.rb', line 16

def self.width(pack)
  case pack
  when 'L' then 4
  when 'S' then 2
  when /^a(\d+)$/ then Regexp.last_match[1].to_i
  when 'a*' then nil
  end
end

Instance Method Details

#dependentObject

XXX unspec



11
12
13
# File 'lib/zippo/binary_structure/structure_member.rb', line 11

def dependent
  options[:size]
end

#signature?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/zippo/binary_structure/structure_member.rb', line 26

def signature?
  options[:signature]
end