Class: Gamerom::GameInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/gamerom/game_info.rb

Overview

GameInfo - Extracts region and tags from game name

Constant Summary collapse

REGIONS =
{
  '1' => 'Japan & Korea',
  '4' => 'USA & Brazil - NTSC',
  '5' => 'NTSC',
  '8' => 'PAL',
  'A' => 'Australia',
  'As' => 'Asia',
  'B' => 'Brazil',
  'C' => 'Canada',
  'Ch' => 'China',
  'D' => 'Netherlands (Dutch)',
  'E' => 'Europe',
  'F' => 'France',
  'FC' => 'French Canadian',
  'FN' => 'Finland',
  'G' => 'Germany',
  'GR' => 'Greece',
  'H' => 'Holland',
  'HK' => 'Hong Kong',
  'I' => 'Italy',
  'J' => 'Japan',
  'JUE' => 'Japan & USA & Europe',
  'K' => 'Korea',
  'Nl' => 'Netherlands',
  'NL' => 'Netherlands',
  'No' => 'Norway',
  'PD' => 'Public Domain',
  'R' => 'Russia',
  'S' => 'Spain',
  'Sw' => 'Sweden',
  'SW' => 'Sweden',
  'U' => 'USA',
  'UK' => 'England',
  'Unk' => 'Unknown Country',
  'Unl' => 'Unlicensed',
  'PAL' => 'PAL regions (Australia, Europe)',
  'NTSC' => 'NTSC regions (Japan, USA, Latin America)',
}.freeze
TAGS =
{
  '!' => :good,
  '!p' => :pending,
  'a' => :alternate,
  'b' => :bad,
  'BF' => :bung,
  'c' => :checksum,
  'C' => :color,
  'f' => :fixed,
  'h' => :hack,
  'J' => :japanese_translation,
  'o' => :overdump,
  'p' => :pirate,
  'PC10' => :pc10,
  'S' => :super,
  'T-' => :old_translation,
  't' => :trained,
  'T+' => :newer_translation,
  'VS' => :vs,
  'x' => :bad_checksum,
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ GameInfo

Returns a new instance of GameInfo.



69
70
71
# File 'lib/gamerom/game_info.rb', line 69

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



67
68
69
# File 'lib/gamerom/game_info.rb', line 67

def name
  @name
end

Instance Method Details

#regionObject



73
74
75
76
77
78
79
80
81
# 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

#tagsObject



83
84
85
86
87
88
89
90
91
# 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