Class: GamesIndexViewObject

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, release_date, original_title, original_release_date, work_id, platform_title, platform_id, region_title, region_id, description, genres_array, created_at, coverart_url, edition_id, expansion_id) ⇒ GamesIndexViewObject

Returns a new instance of GamesIndexViewObject.


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/games_index_view_object.rb', line 29

def initialize(title, release_date, original_title, original_release_date, work_id, platform_title, platform_id, region_title, region_id, description, genres_array, created_at, coverart_url, edition_id, expansion_id)
	@title = title
	@release_date = Time.iso8601(release_date) if release_date
	@original_title = original_title
	@original_release_date = Time.iso8601(original_release_date) if original_release_date
	@work_id = work_id
	@platform_title = platform_title
	@platform_id = platform_id
	@region_title = region_title
	@region_id = region_id
	@description = description
	@genres_array = genres_array
	@created_at = created_at
	@coverart_url = coverart_url
	@edition_id = edition_id
	@expansion_id = expansion_id
end

Instance Attribute Details

#coverart_urlObject (readonly)

Returns the value of attribute coverart_url


12
13
14
# File 'lib/games_index_view_object.rb', line 12

def coverart_url
  @coverart_url
end

#created_atObject (readonly)

Returns the value of attribute created_at


12
13
14
# File 'lib/games_index_view_object.rb', line 12

def created_at
  @created_at
end

#descriptionObject (readonly)

Returns the value of attribute description


12
13
14
# File 'lib/games_index_view_object.rb', line 12

def description
  @description
end

#edition_idObject (readonly)

Returns the value of attribute edition_id


12
13
14
# File 'lib/games_index_view_object.rb', line 12

def edition_id
  @edition_id
end

#expansion_idObject (readonly)

Returns the value of attribute expansion_id


12
13
14
# File 'lib/games_index_view_object.rb', line 12

def expansion_id
  @expansion_id
end

#genres_arrayObject (readonly)

Returns the value of attribute genres_array


12
13
14
# File 'lib/games_index_view_object.rb', line 12

def genres_array
  @genres_array
end

#original_release_dateObject (readonly)

Returns the value of attribute original_release_date


12
13
14
# File 'lib/games_index_view_object.rb', line 12

def original_release_date
  @original_release_date
end

#original_titleObject (readonly)

Returns the value of attribute original_title


12
13
14
# File 'lib/games_index_view_object.rb', line 12

def original_title
  @original_title
end

#platform_idObject (readonly)

Returns the value of attribute platform_id


12
13
14
# File 'lib/games_index_view_object.rb', line 12

def platform_id
  @platform_id
end

#platform_titleObject (readonly)

Returns the value of attribute platform_title


12
13
14
# File 'lib/games_index_view_object.rb', line 12

def platform_title
  @platform_title
end

#region_idObject (readonly)

Returns the value of attribute region_id


12
13
14
# File 'lib/games_index_view_object.rb', line 12

def region_id
  @region_id
end

#region_titleObject (readonly)

Returns the value of attribute region_title


12
13
14
# File 'lib/games_index_view_object.rb', line 12

def region_title
  @region_title
end

#release_dateObject (readonly)

Returns the value of attribute release_date


12
13
14
# File 'lib/games_index_view_object.rb', line 12

def release_date
  @release_date
end

#titleObject (readonly)

Returns the value of attribute title


12
13
14
# File 'lib/games_index_view_object.rb', line 12

def title
  @title
end

#work_idObject (readonly)

Returns the value of attribute work_id


12
13
14
# File 'lib/games_index_view_object.rb', line 12

def work_id
  @work_id
end

Class Method Details

.construct_array_from_chewy_map(map) ⇒ Object


2
3
4
5
6
7
8
9
10
# File 'lib/games_index_view_object.rb', line 2

def self.construct_array_from_chewy_map(map)
	constructed_array = []

	map.each do |item|
		constructed_array << GamesIndexViewObject.new(item.title, item.release_date, item.original_title, item.original_release_date, item.work_id, item.platform, item.platform_id, item.region, item.region_id, item.description, item.genres, item.created_at, item.coverart_url, item.edition_id, item.expansion_id)
	end

	return constructed_array
end

Instance Method Details


14
15
16
17
18
19
20
# File 'lib/games_index_view_object.rb', line 14

def link
	if @expansion_id.present?
		Rails.application.routes.url_helpers.edition_expansion_path(@edition_id, @expansion_id)
	else
		Rails.application.routes.url_helpers.edition_path(@edition_id)
	end
end

#objObject


21
22
23
24
25
26
27
# File 'lib/games_index_view_object.rb', line 21

def obj
	if @expansion_id.present?
		Expansion.new(edition_id: @edition_id, id: @expansion_id)
	else
		Edition.new(id: @edition_id)
	end
end