Sha256: 843ffc087927955454ff98f49300f214ad5b0225c01857330e3981f8bab80e61

Contents?: true

Size: 482 Bytes

Versions: 1

Compression:

Stored size: 482 Bytes

Contents

module DMAPParser
  # The Tag class
  class Tag < Struct.new(:type, :value)
    def to_s
      "#<#{self.class.name} #{type}>"
    end

    def inspect(level = 0)
      "#{'  ' * level}#{type}: #{value}"
    end

    def to_dmap
      value = convert_value(self.value)
      length = [value.length].pack('N')
      (type.tag.to_s + length + value).force_encoding('utf-8')
    end

    private

    def convert_value(value)
      Converter.encode(type.type, value)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dmapparser-0.0.1 lib/dmapparser/tag.rb