class RGFA::ByteArray
Array
of positive integers <= 255; representation of the data contained in an H field
Public Instance Methods
default_gfa_datatype()
click to toggle source
@!macro gfa_datatype
# File lib/rgfa/field_writer.rb, line 97 def default_gfa_datatype; :H; end
to_byte_array()
click to toggle source
Returns self @return [RGFA::ByteArray] self
# File lib/rgfa/byte_array.rb, line 27 def to_byte_array self end
to_s()
click to toggle source
GFA datatype H representation of the byte array @raise [RGFA::ByteArray::ValueError] if the
array is not a valid byte array
@return [String]
# File lib/rgfa/byte_array.rb, line 35 def to_s validate! map do |elem| str = elem.to_s(16).upcase elem < 16 ? "0#{str}" : str end.join end
validate!()
click to toggle source
Validates the byte array content @raise [RGFA::ByteArray::ValueError] if any value is not a
positive integer <= 255
@return [void]
# File lib/rgfa/byte_array.rb, line 13 def validate! each do |x| unless x.kind_of?(Integer) and (0..255).include?(x) raise RGFA::ByteArray::ValueError, "Value incompatible with byte array: #{x.inspect}\n"+ "in array: #{self.inspect}" end end self.trust return nil end
validate_gfa_field!(datatype, fieldname=nil)
click to toggle source
@!macro validate_gfa_field
# File lib/rgfa/field_validator.rb, line 155 def validate_gfa_field!(datatype, fieldname=nil) if datatype != :H raise RGFA::FieldParser::FormatError, "Wrong type (#{self.class}) for field #{fieldname}\n"+ "Content: #{self.inspect}\n"+ "Datatype: #{datatype}" end begin validate! rescue => err raise RGFA::FieldParser::FormatError, "Invalid content for field #{fieldname}\n"+ "Content: #{self.inspect}\n"+ "Datatype: #{datatype}\n"+ "Error: #{err}" end end