Class: MediaInfo

Inherits:
CLIChef::Cookbook show all
Defined in:
lib/cli_chef/apps/media_info.rb

Instance Method Summary collapse

Methods inherited from CLIChef::Cookbook

#execute, #execute!, ingredient, #menu, method_missing, #prepare, #prepare_args, prototype, #ready?, respond_to_missing?, #run, #run!

Instance Method Details

#helpObject



25
26
27
# File 'lib/cli_chef/apps/media_info.rb', line 25

def help
  run!(help: true).body
end

#info(file, full = false) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/cli_chef/apps/media_info.rb', line 33

def info(file, full = false)
  run!(file: file, full: full).body.split("\n\n").hmap do |category|
    lines = category.split("\n")
    next if lines.empty?
    [
      lines.shift.strip.downcase.method_case,
      lines.hmap do |line|
        key, value = line.split(':', 2)
        key = key.downcase.method_case.to_sym
        [
          key,
          convert_value(key, value.strip)
        ]
      end
    ]
  end.keys_to_sym
end

#versionObject



29
30
31
# File 'lib/cli_chef/apps/media_info.rb', line 29

def version
  run!(version: true).body.scan(/(?<= v)\d+\.\d+.*/).first
end