Class: DACPClient::Tag

Inherits:
Struct
  • Object
show all
Defined in:
lib/dacpclient/tag.rb

Direct Known Subclasses

TagContainer

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



2
3
4
# File 'lib/dacpclient/tag.rb', line 2

def type
  @type
end

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



2
3
4
# File 'lib/dacpclient/tag.rb', line 2

def value
  @value
end

Instance Method Details

#inspect(level = 0) ⇒ Object



7
8
9
# File 'lib/dacpclient/tag.rb', line 7

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

#to_dmapObject



11
12
13
14
15
16
17
18
19
# File 'lib/dacpclient/tag.rb', line 11

def to_dmap
  value = self.value
  if type.type == :container
    value = value.reduce('') { |a, e| a + e.to_dmap }
  else
    value = DMAPConverter.encode(type.type, value)
  end
  type.tag.to_s + [value.length].pack('N') + value
end

#to_sObject



3
4
5
# File 'lib/dacpclient/tag.rb', line 3

def to_s
  "#<#{self.class.name} #{type}>"
end