Class: GamesRadar::Genre

Inherits:
Object
  • Object
show all
Defined in:
lib/games_radar/genre.rb

Constant Summary collapse

GENRES =
{
  "1"  => :action,
  "2"  => :fighting,
  "3"  => :adventure,
  "4"  => :arcade,
  "5"  => :racing,
  "6"  => :shooter,
  "7"  => :flight,
  "8"  => :strategy,
  "9"  => :rpg,
  "10" => :sports,
  "11" => :other,
  "12" => :family,
  "13" => :children,
  "14" => :puzzle,
  "15" => :simulation
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ Genre

Set up genre attributes based on the specified id. The available genres can be found on the GamesRadar::Genre::GENRES constant.



29
30
31
32
33
34
# File 'lib/games_radar/genre.rb', line 29

def initialize(id)
  @id = id.to_s
  @name = GENRES[@id]

  raise GamesRadar::UnknownGenreError unless name
end

Instance Attribute Details

#idObject (readonly)

The genre id



22
23
24
# File 'lib/games_radar/genre.rb', line 22

def id
  @id
end

#nameObject (readonly)

The genre name



25
26
27
# File 'lib/games_radar/genre.rb', line 25

def name
  @name
end