Class: LatestGames::SwitchGame

Inherits:
Object
  • Object
show all
Defined in:
lib/latest_games/switchgame.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil, url = nil) ⇒ SwitchGame

Returns a new instance of SwitchGame.



4
5
6
7
# File 'lib/latest_games/switchgame.rb', line 4

def initialize(name = nil, url = nil)
  @name = name
  @url = url
end

Instance Attribute Details

#also_onObject

Returns the value of attribute also_on.



2
3
4
# File 'lib/latest_games/switchgame.rb', line 2

def also_on
  @also_on
end

#metascoreObject

Returns the value of attribute metascore.



2
3
4
# File 'lib/latest_games/switchgame.rb', line 2

def metascore
  @metascore
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/latest_games/switchgame.rb', line 2

def name
  @name
end

#publisherObject

Returns the value of attribute publisher.



2
3
4
# File 'lib/latest_games/switchgame.rb', line 2

def publisher
  @publisher
end

#release_dateObject

Returns the value of attribute release_date.



2
3
4
# File 'lib/latest_games/switchgame.rb', line 2

def release_date
  @release_date
end

#summaryObject

Returns the value of attribute summary.



2
3
4
# File 'lib/latest_games/switchgame.rb', line 2

def summary
  @summary
end

#urlObject

Returns the value of attribute url.



2
3
4
# File 'lib/latest_games/switchgame.rb', line 2

def url
  @url
end

Class Method Details

.allObject



9
10
11
# File 'lib/latest_games/switchgame.rb', line 9

def self.all
  @@all ||= scrape_switch_games
end

.find(i) ⇒ Object



13
14
15
# File 'lib/latest_games/switchgame.rb', line 13

def self.find(i)
  self.all[i-1]
end

.find_by_name(name) ⇒ Object



17
18
19
20
21
22
# File 'lib/latest_games/switchgame.rb', line 17

def self.find_by_name(name)
  self.all.detect do |game|
    game.name.downcase.strip == name.downcase.strip ||
    game.name.split("(").first.strip.downcase == name.downcase.strip
  end
end