class DMAPParser::Tag

The Tag class

Public Class Methods

new(type, value) click to toggle source
Calls superclass method
# File lib/dmapparser/tag.rb, line 4
def initialize(type, value)
  unless type.is_a? TagDefinition
    type = TagDefinition[type] ||
           TagDefinition.new(type, :unknown, "unknown (#{length})")
  end
  super
end

Public Instance Methods

inspect(level = 0) click to toggle source
# File lib/dmapparser/tag.rb, line 16
def inspect(level = 0)
  "#{'  ' * level}#{type}: #{value}"
end
to_dmap() click to toggle source
# File lib/dmapparser/tag.rb, line 20
def to_dmap
  value = convert_value(self.value)
  length = [value.length].pack('N')
  (type.tag.to_s + length + value).force_encoding(Encoding::BINARY)
end
to_s() click to toggle source
# File lib/dmapparser/tag.rb, line 12
def to_s
  "#<#{self.class.name} #{type}>"
end

Private Instance Methods

convert_value(value) click to toggle source
# File lib/dmapparser/tag.rb, line 28
def convert_value(value)
  Converter.encode(type.type, value)
end