Repository navigation
Expand file tree
/
Copy pathtron.rb
More file actions
161 lines (142 loc) · 3.63 KB
/
Copy pathtron.rb
File metadata and controls
161 lines (142 loc) · 3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# frozen_string_literal: true
module Faker
class Movies
class Tron < Base
class << self
##
# Produces a character from Tron.
#
# @return [String]
#
# @example
# Faker::Movies::Tron.character #=> "Bit"
#
# @faker.version next
def character
sample(characters)
end
##
# Produces a game from Tron.
#
# @return [String]
#
# @example
# Faker::Movies::Tron.game #=> "Space Paranoids"
#
# @faker.version next
def game
sample(games)
end
##
# Produces a location from Tron.
#
# @return [String]
#
# @example
# Faker::Movies::Tron.location #=> "Flynn's Arcade"
#
# @faker.version next
def location
sample(locations)
end
##
# Produces a program from Tron.
#
# @return [String]
#
# @example
# Faker::Movies::Tron.program #=> "Clu"
#
# @faker.version next
def program
sample(programs)
end
##
# Produces a quote from Tron.
#
# @param character [String] The name of a character to derive a quote from.
# @return [String]
#
# @example
# Faker::Movies::Tron.quote #=> "Greetings, Programs!"
#
# @example
# Faker::Movies::Tron.quote(character: "mcp")
# #=> "End of Line."
#
# @faker.version next
def quote(character: nil)
quoted_characters = translate('faker.tron.quotes')
if character.nil?
character = sample(quoted_characters.keys).to_s
else
character = character.to_s.downcase
# check alternate spellings, nicknames, titles of characters
translate('faker.tron.alternate_character_spellings').each do |k, v|
character = k.to_s if v.include?(character)
end
raise ArgumentError, "Character for quotes can be left blank or #{quoted_characters.keys.join(', ')}" unless quoted_characters.key?(character.to_sym)
end
fetch("tron.quotes.#{character}")
end
##
# Produces a tagline from Tron.
#
# @return [String]
#
# @example
# Faker::Movies::Tron.tagline #=> "The Electronic Gladiator"
#
# @faker.version next
def tagline
sample(taglines)
end
##
# Produces a user from Tron.
#
# @return [String]
#
# @example
# Faker::Movies::Tron.user #=> "Light Cycle"
#
# @faker.version next
def user
sample(users)
end
##
# Produces a vehicle from Tron.
#
# @return [String]
#
# @example
# Faker::Movies::Tron.vehicle #=> "Light Cycle"
#
# @faker.version next
def vehicle
sample(vehicles)
end
def characters
translate('faker.tron.characters').values.flatten
end
def games
fetch_all('tron.games')
end
def locations
fetch_all('tron.locations')
end
def programs
fetch_all('tron.characters.programs')
end
def taglines
fetch_all('tron.taglines')
end
def users
fetch_all('tron.characters.users')
end
def vehicles
fetch_all('tron.vehicles')
end
end
end
end
end