Class: EhbrsRubyUtils::Vg::Ps2::IsoFile

Inherits:
Fs::Iso9660File show all
Defined in:
lib/ehbrs_ruby_utils/vg/ps2/iso_file.rb

Constant Summary collapse

CODE_PATTERN =
/[a-zA-Z]{4}_[0-9]{3}\.[0-9]{2}/.freeze
CODE_PARSER =
CODE_PATTERN.to_parser(&:to_s)

Constants inherited from Fs::Iso9660File

Fs::Iso9660File::DEFAULT_EXTNAME

Instance Method Summary collapse

Methods inherited from Fs::Iso9660File

#isoinfo_command, #list

Instance Method Details

#basename_nocode_noextString

Returns:

  • (String)


19
20
21
# File 'lib/ehbrs_ruby_utils/vg/ps2/iso_file.rb', line 19

def basename_nocode_noext
  path.basename_noext.to_path.gsub(/\A#{::Regexp.quote(code)}/, '')
end

#codeString

Returns:

  • (String)


14
15
16
# File 'lib/ehbrs_ruby_utils/vg/ps2/iso_file.rb', line 14

def code
  list.lazy.map { |line| CODE_PARSER.parse(line) }.find(&:present?)
end

#target_pathPath

Returns:

  • (Path)


24
25
26
27
28
# File 'lib/ehbrs_ruby_utils/vg/ps2/iso_file.rb', line 24

def target_path
  path.basename_sub do |_b|
    "#{code}.#{path_basename}#{DEFAULT_EXTNAME}"
  end
end

#valid?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/ehbrs_ruby_utils/vg/ps2/iso_file.rb', line 31

def valid?
  super && code.present?
end