Class: RMD::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/rmd/processor.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(link, options = {}) ⇒ Processor

Returns a new instance of Processor.



9
10
11
12
# File 'lib/rmd/processor.rb', line 9

def initialize(link, options = {})
  @link = link
  @options = options
end

Instance Attribute Details

Returns the value of attribute link.



7
8
9
# File 'lib/rmd/processor.rb', line 7

def link
  @link
end

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/rmd/processor.rb', line 7

def options
  @options
end

Class Method Details

.process(link, options = {}) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/rmd/processor.rb', line 30

def self.process(link, options = {})
  begin
    new(link, options).process
  rescue => e
    puts e.message.red
    puts 'Errors! Can not continue!'.red
  end
end

Instance Method Details

#processObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rmd/processor.rb', line 14

def process
  puts "Start processing #{link}...".green
  playlist = RMD::Factory.build(link)
  playlist.fetch

  if playlist.success?
    playlist.songs.each do |song|
      download(song)
    end
  end

  playlist.errors.each do |error|
    puts error.red
  end
end