Class: GameFaqs::Platform

Inherits:
Object
  • Object
show all
Defined in:
lib/gamefaqs/platform.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Platform

Returns a new instance of Platform.



6
7
8
9
10
11
# File 'lib/gamefaqs/platform.rb', line 6

def initialize(params={})
  raise ArgumentError("Need at least the name, homepage, and id of the platform!") unless params[:name] && params[:homepage] && params[:id]
  @name = params[:name]
  @homepage = "#{GameFaqs::BASE_URL}#{params[:homepage]}"
  @id = params[:id] if params[:id]
end

Instance Attribute Details

#homepageObject (readonly)

Returns the value of attribute homepage.



4
5
6
# File 'lib/gamefaqs/platform.rb', line 4

def homepage
  @homepage
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/gamefaqs/platform.rb', line 4

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/gamefaqs/platform.rb', line 4

def name
  @name
end

Class Method Details

.allObject



17
18
19
# File 'lib/gamefaqs/platform.rb', line 17

def self.all
  List.platforms
end

.all_gamesObject



25
26
27
# File 'lib/gamefaqs/platform.rb', line 25

def self.all_games
  List.games(self)
end

.all_idsObject



21
22
23
# File 'lib/gamefaqs/platform.rb', line 21

def self.all_ids
  List.platform_ids
end

.find(platform_name) ⇒ Object

create case insensitive



34
35
36
# File 'lib/gamefaqs/platform.rb', line 34

def self.find(platform_name)
  Search.platform(platform_name)
end

Instance Method Details

#find(game, refresh = false) ⇒ Object



29
30
31
# File 'lib/gamefaqs/platform.rb', line 29

def find(game, refresh=false)
  Search.game(game, self, refresh)
end

#to_sObject



13
14
15
# File 'lib/gamefaqs/platform.rb', line 13

def to_s
  @name
end