class Gamerom::GameInfo

GameInfo - Extracts region and tags from game name

Constants

REGIONS
TAGS

Attributes

name[R]

Public Class Methods

new(name) click to toggle source
# File lib/gamerom/game_info.rb, line 69
def initialize(name)
  @name = name
end

Public Instance Methods

region() click to toggle source
# File lib/gamerom/game_info.rb, line 73
def region
  identifiers = @name.scan(/\((?<region>[A-Za-z0-9]+)\)/).flatten
  region_id = identifiers.find { |i| REGIONS.include? i }
  if region_id
    REGIONS[region_id]
  else
    'USA'
  end
end
tags() click to toggle source
# File lib/gamerom/game_info.rb, line 83
def tags
  tags = []
  codes = @name.scan(/\[(?<code>[^\]]+)\]/).flatten
  codes.each do |code|
    code = Regexp.last_match(1) if code.match /^(?<code>[abcfhop])[0-9]*/
    tags << TAGS[code] if TAGS.include?(code)
  end
  tags
end