class DMAPParser::TagContainer
The TagContainer
class is a Tag
which contains other Tags
Public Class Methods
new(type, value = [])
click to toggle source
Calls superclass method
DMAPParser::Tag::new
# File lib/dmapparser/tag_container.rb, line 4 def initialize(type, value = []) super end
Public Instance Methods
get_tag(key)
click to toggle source
# File lib/dmapparser/tag_container.rb, line 21 def get_tag(key) key = key.to_s value.find { |e| e.type.tag == key || e.type.name == key } end
get_value(key)
click to toggle source
# File lib/dmapparser/tag_container.rb, line 14 def get_value(key) return value[key] if key.is_a? Fixnum tag = get_tag(key) return unless tag tag.type.container? ? tag : tag.value end
Also aliased as: []
has?(key)
click to toggle source
# File lib/dmapparser/tag_container.rb, line 28 def has?(key) !get_tag(key).nil? end
inspect(level = 0)
click to toggle source
# File lib/dmapparser/tag_container.rb, line 8 def inspect(level = 0) "#{' ' * level}#{type}:\n" + value.reduce('') do |a, e| a + e.inspect(level + 1).chomp + "\n" end end
method_missing(method, *_arguments, &_block)
click to toggle source
# File lib/dmapparser/tag_container.rb, line 32 def method_missing(method, *_arguments, &_block) if method =~ /(.*)\?$/ has?(Regexp.last_match[1]) elsif has?(method) get_value(method) else nil end end
respond_to?(method)
click to toggle source
Calls superclass method
# File lib/dmapparser/tag_container.rb, line 42 def respond_to?(method) method.to_s.match(/(.*)\??$/) has?(Regexp.last_match[1]) || super end
to_a()
click to toggle source
# File lib/dmapparser/tag_container.rb, line 47 def to_a value end
Private Instance Methods
convert_value(value)
click to toggle source
# File lib/dmapparser/tag_container.rb, line 53 def convert_value(value) value.reduce('') { |a, e| a + e.to_dmap } end