Class: Cejo::Media::Get
- Inherits:
-
Object
- Object
- Cejo::Media::Get
- Defined in:
- lib/cejo/media/get/get.rb
Overview
Get media pointed in url.
Constant Summary collapse
- AUDIO_DIR =
Pathname.new(Dir.home).join('Music')
- VIDEO_DIR =
Pathname.new(Dir.home).join('Videos')
- AUDIO_FORMATS =
%w[vorbis flac mp3].freeze
- VIDEO_FORMATS =
%w[mkv mp4 ogg].freeze
Instance Attribute Summary collapse
-
#info ⇒ Object
readonly
Returns the value of attribute info.
Instance Method Summary collapse
- #current_dir ⇒ Object
- #exec ⇒ Object
- #final_command ⇒ Object
-
#initialize(info) ⇒ Get
constructor
A new instance of Get.
- #show_info ⇒ Object
Constructor Details
#initialize(info) ⇒ Get
Returns a new instance of Get.
16 17 18 |
# File 'lib/cejo/media/get/get.rb', line 16 def initialize(info) @info = info end |
Instance Attribute Details
#info ⇒ Object (readonly)
Returns the value of attribute info.
14 15 16 |
# File 'lib/cejo/media/get/get.rb', line 14 def info @info end |
Instance Method Details
#current_dir ⇒ Object
20 21 22 |
# File 'lib/cejo/media/get/get.rb', line 20 def current_dir AUDIO_FORMATS.include?(info.codec) ? AUDIO_DIR : VIDEO_DIR end |
#exec ⇒ Object
39 40 41 42 43 |
# File 'lib/cejo/media/get/get.rb', line 39 def exec show_info Dir.chdir(current_dir) { system final_command } end |
#final_command ⇒ Object
24 25 26 |
# File 'lib/cejo/media/get/get.rb', line 24 def final_command AUDIO_FORMATS.include?(info.codec) ? info.audio_command : info.video_command end |
#show_info ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/cejo/media/get/get.rb', line 28 def show_info puts <<~INFO Title: #{info.title} Url: #{info.url} Codec: #{info.codec} Folder: #{current_dir} INFO puts end |