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



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

def self.process(link, options = {})
  begin
    new(link, options).process
  rescue => error
    puts error.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
# File 'lib/rmd/processor.rb', line 14

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

  if playlist.success?
    strategy.process(playlist.songs)
  end

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