Class: Cejo::Media::Info

Inherits:
Object
  • Object
show all
Defined in:
lib/cejo/media/get/info.rb

Overview

Media information

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, codec, current) ⇒ Info

Returns a new instance of Info.



12
13
14
15
16
17
# File 'lib/cejo/media/get/info.rb', line 12

def initialize(url, codec, current)
  @url = url
  @codec = codec
  @current = current
  @parser = Cejo::Media::Parser.new(current, url)
end

Instance Attribute Details

#codecObject

Returns the value of attribute codec.



10
11
12
# File 'lib/cejo/media/get/info.rb', line 10

def codec
  @codec
end

#currentObject (readonly)

Returns the value of attribute current.



9
10
11
# File 'lib/cejo/media/get/info.rb', line 9

def current
  @current
end

#parserObject

Returns the value of attribute parser.



10
11
12
# File 'lib/cejo/media/get/info.rb', line 10

def parser
  @parser
end

#urlObject (readonly)

Returns the value of attribute url.



9
10
11
# File 'lib/cejo/media/get/info.rb', line 9

def url
  @url
end

Instance Method Details

#audio_commandObject



27
28
29
# File 'lib/cejo/media/get/info.rb', line 27

def audio_command
  "#{program} -o '#{title}.#{current.ext}' #{current.audio} #{codec} #{url}"
end

#extensionObject



43
44
45
46
# File 'lib/cejo/media/get/info.rb', line 43

def extension
  parser.fmt = :ext
  parser.result
end

#programObject



19
20
21
# File 'lib/cejo/media/get/info.rb', line 19

def program
  current.name
end

#shorter_title(title) ⇒ Object



36
37
38
39
40
41
# File 'lib/cejo/media/get/info.rb', line 36

def shorter_title(title)
  max_words = 6
  fixed = title.split[0...max_words].join(' ')

  title.split.size > max_words ? fixed : title
end

#titleObject



31
32
33
34
# File 'lib/cejo/media/get/info.rb', line 31

def title
  parser.fmt = :title
  shorter_title parser.result
end

#to_sObject



48
49
50
# File 'lib/cejo/media/get/info.rb', line 48

def to_s
  "#{title}.#{extension}"
end

#video_commandObject



23
24
25
# File 'lib/cejo/media/get/info.rb', line 23

def video_command
  "#{program} -o '#{title}.#{current.ext}' #{current.video} #{codec} #{url}"
end