class RakeMKV::Parser
Constants
- CINFO_REGEX
- DRIVES_REGEX
- MSG_REGEX
- SINFO_REGEX
- TINFO_REGEX
Attributes
raw[R]
Public Class Methods
new(raw_info)
click to toggle source
Initialize using info received from disc
# File lib/rakemkv/parser.rb, line 12 def initialize(raw_info) @raw = raw_info end
Public Instance Methods
cinfo()
click to toggle source
Grab information from cinfo
# File lib/rakemkv/parser.rb, line 17 def cinfo cinfo = {} parse(CINFO_REGEX) do |code, info| code = RakeMKV::Code[code] cinfo[code] = info end cinfo end
drives()
click to toggle source
Grab information from discs
# File lib/rakemkv/parser.rb, line 61 def drives drives = [] parse(DRIVES_REGEX) do |accessible, drive_name, disc_name, location| drives << { accessible: accessible(accessible), drive_name: drive_name, disc_name: disc_name, location: location } end drives end
messages()
click to toggle source
Grab information from messages
# File lib/rakemkv/parser.rb, line 52 def messages messages = [] parse(MSG_REGEX) do |info| messages << info.first end messages end
sinfo()
click to toggle source
Grab information from sinfo
# File lib/rakemkv/parser.rb, line 38 def sinfo sinfo = [] parse(SINFO_REGEX) do |title_id, section_id, code, info| code = RakeMKV::Code[code] title = title_id.to_i section = section_id.to_i sinfo[title] ||= Array.new sinfo[title][section] ||= Hash.new sinfo[title][section][code] = info end sinfo end
tinfo()
click to toggle source
Grab information from tinfo
# File lib/rakemkv/parser.rb, line 27 def tinfo tinfo = [] parse(TINFO_REGEX) do |title_id, code, info| code = RakeMKV::Code[code] tinfo[title_id.to_i] ||= Hash.new tinfo[title_id.to_i][code] = info end tinfo end
Private Instance Methods
accessible(accessible)
click to toggle source
# File lib/rakemkv/parser.rb, line 76 def accessible(accessible) accessible != '0' end
parse(regex, &block)
click to toggle source
# File lib/rakemkv/parser.rb, line 80 def parse(regex, &block) raw.split('\n').each do |line| line.scan(regex, &block) end end