Class: AudioAddict::Youtube

Inherits:
Object
  • Object
show all
Includes:
Inspectable, Colsole
Defined in:
lib/audio_addict/youtube.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Inspectable

#inspect

Constructor Details

#initialize(query) ⇒ Youtube

Returns a new instance of Youtube.



8
9
10
# File 'lib/audio_addict/youtube.rb', line 8

def initialize(query)
  @query = query
end

Instance Attribute Details

#queryObject (readonly)

Returns the value of attribute query.



6
7
8
# File 'lib/audio_addict/youtube.rb', line 6

def query
  @query
end

Instance Method Details

#command(args) ⇒ Object



24
25
26
# File 'lib/audio_addict/youtube.rb', line 24

def command(args)
  command_template % args
end

#get(count = nil) ⇒ Object

Raises:



16
17
18
19
20
21
22
# File 'lib/audio_addict/youtube.rb', line 16

def get(count = nil)
  count ||= 1
  raise DependencyError, 'This command requires youtube-dl' unless command_exist? 'youtube-dl'

  success = execute command(count: count, query: query)
  raise DependencyError, 'youtube-dl exited with an error' unless success
end

#inspectableObject



12
13
14
# File 'lib/audio_addict/youtube.rb', line 12

def inspectable
  [:query]
end