Class: BinaryParser::BuiltInTemplate::Binary

Inherits:
TemplateBase show all
Defined in:
lib/binary_parser/built_in_template/binary.rb

Constant Summary

Constants included from BinaryParser::BuiltInTemplate

BCD, BCD_f1, BCD_f10, BCD_f2, BCD_f3, BCD_f4, BCD_f5, BCD_f6, BCD_f7, BCD_f8, BCD_f9

Instance Method Summary collapse

Methods inherited from TemplateBase

Def, #[], #binary_bit_length, #convert_into_abstract_binary, def_structure, def_var_method, #hold_enough_binary?, #hold_just_binary?, #initialize, #load, #names, #show, structure, #structure_bit_length, #to_chars, #to_i, #to_s

Methods included from BinaryParser::BuiltInTemplate

bcd_make

Constructor Details

This class inherits a constructor from BinaryParser::TemplateBase

Instance Method Details

#==(other) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/binary_parser/built_in_template/binary.rb', line 14

def ==(other)
  if other.is_a?(Binary)
    self.to_s == other.to_s
  elsif other.is_a?(String)
    self.to_s == other
  else
    super
  end
end

#content_descriptionObject



4
5
6
7
8
# File 'lib/binary_parser/built_in_template/binary.rb', line 4

def content_description
  chars = to_chars
  bytes = chars[0, 5].map{|i| sprintf("0x%02x", i)}.join(", ")
  return "[" + bytes + (chars.length > 5 ? ", ..." : "") + "]"
end

#to_strObject



10
11
12
# File 'lib/binary_parser/built_in_template/binary.rb', line 10

def to_str
  self.to_s
end