class XbmcSql::NfoFile

Constants

PLURAL_ATTRIBUTES
SIMPLE_ATTRIBUTES

Attributes

raw_file[RW]

Public Class Methods

new(raw_file) click to toggle source
# File lib/xbmc_sql/nfo_file.rb, line 7
def initialize(raw_file)
  @raw_file = raw_file
end

Public Instance Methods

audio_streams() click to toggle source
# File lib/xbmc_sql/nfo_file.rb, line 59
def audio_streams
  streams['audio']
end
doc() click to toggle source
# File lib/xbmc_sql/nfo_file.rb, line 15
def doc
  @doc ||= XmlSimple.xml_in(File.read(@raw_file))
end
new_doc() click to toggle source
# File lib/xbmc_sql/nfo_file.rb, line 19
def new_doc
  out = XmlSimple.xml_out doc,
    xmldeclaration: '<?xml version="1.0" encoding="utf-8"?>',
    rootname:       'movie',
    noescape:       true
  out.gsub /<([^>]+)>\s*<\/\1>/, '<\1 />'
end
save!() click to toggle source
# File lib/xbmc_sql/nfo_file.rb, line 11
def save!
  File.open(raw_file, 'w+') { |f| f.write new_doc }
end
sub_streams() click to toggle source
# File lib/xbmc_sql/nfo_file.rb, line 63
def sub_streams
  streams['sub']
end
video_stream() click to toggle source
# File lib/xbmc_sql/nfo_file.rb, line 67
def video_stream
  video_streams[0]
end
video_streams() click to toggle source

File info

# File lib/xbmc_sql/nfo_file.rb, line 55
def video_streams
  streams['video']
end

Private Instance Methods

streams() click to toggle source
# File lib/xbmc_sql/nfo_file.rb, line 73
def streams
  doc['fileinfo'][0]['streamdetails'][0]
end