Class: Hindbaer::Info

Inherits:
Object
  • Object
show all
Defined in:
lib/hindbaer/info.rb

Constant Summary collapse

ATTRIBUTES =
%w{
name title subtitle author link email
description album track artist composer
date genre copyright explicit keywords
identifier reference
}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Info

Returns a new instance of Info.



23
24
25
26
27
# File 'lib/hindbaer/info.rb', line 23

def initialize(&block)
  self.keywords = []
  
  block.arity > 0 ? block.call(self) : instance_eval(&block)
end

Class Method Details

.parse(fragment) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/hindbaer/info.rb', line 13

def self.parse(fragment)
  new do
    ATTRIBUTES.each do |attribute|
      self.send("#{attribute.to_sym}=", fragment[attribute.capitalize])
    end
    
    self.keywords = keywords.split(',').map &:strip
  end
end

Instance Method Details

#to_xml(xml) ⇒ Object



29
30
31
# File 'lib/hindbaer/info.rb', line 29

def to_xml(xml)
  xml.Info Subtitle: subtitle, Album: album, Composer: composer, Track: track, Genre: genre, Author: author, Link: link, Email: email, Description: description, Artist: artist, Date: date, Title: title, Explicit: explicit, Copyright: copyright, Identifier: identifier, Keywords: keywords.join(', '), Reference: reference
end