Class: DMAPParser::Tag
- Inherits:
-
Struct
- Object
- Struct
- DMAPParser::Tag
- Defined in:
- lib/dmapparser/tag.rb
Overview
The Tag class
Direct Known Subclasses
Instance Attribute Summary collapse
-
#type ⇒ Object
Returns the value of attribute type.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(type, value) ⇒ Tag
constructor
A new instance of Tag.
- #inspect(level = 0) ⇒ Object
- #to_dmap ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(type, value) ⇒ Tag
Returns a new instance of Tag.
4 5 6 7 8 9 10 |
# 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 |
Instance Attribute Details
#type ⇒ Object
Returns the value of attribute type
3 4 5 |
# File 'lib/dmapparser/tag.rb', line 3 def type @type end |
#value ⇒ Object
Returns the value of attribute value
3 4 5 |
# File 'lib/dmapparser/tag.rb', line 3 def value @value end |
Instance Method Details
#inspect(level = 0) ⇒ Object
16 17 18 |
# File 'lib/dmapparser/tag.rb', line 16 def inspect(level = 0) "#{' ' * level}#{type}: #{value}" end |
#to_dmap ⇒ Object
20 21 22 23 24 |
# 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 ⇒ Object
12 13 14 |
# File 'lib/dmapparser/tag.rb', line 12 def to_s "#<#{self.class.name} #{type}>" end |