Class: Lishogi::UserPreferences

Inherits:
Object
  • Object
show all
Defined in:
lib/lishogi/models/user_preferences.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ UserPreferences

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# File 'lib/lishogi/models/user_preferences.rb', line 177

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Lishogi::UserPreferences` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `Lishogi::UserPreferences`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'dark')
    self.dark = attributes[:'dark']
  end

  if attributes.key?(:'transp')
    self.transp = attributes[:'transp']
  end

  if attributes.key?(:'bg_img')
    self.bg_img = attributes[:'bg_img']
  end

  if attributes.key?(:'theme')
    self.theme = attributes[:'theme']
  end

  if attributes.key?(:'piece_set')
    self.piece_set = attributes[:'piece_set']
  end

  if attributes.key?(:'sound_set')
    self.sound_set = attributes[:'sound_set']
  end

  if attributes.key?(:'blindfold')
    self.blindfold = attributes[:'blindfold']
  end

  if attributes.key?(:'takeback')
    self.takeback = attributes[:'takeback']
  end

  if attributes.key?(:'moretime')
    self.moretime = attributes[:'moretime']
  end

  if attributes.key?(:'clock_tenths')
    self.clock_tenths = attributes[:'clock_tenths']
  end

  if attributes.key?(:'clock_bar')
    self.clock_bar = attributes[:'clock_bar']
  end

  if attributes.key?(:'clock_sound')
    self.clock_sound = attributes[:'clock_sound']
  end

  if attributes.key?(:'premove')
    self.premove = attributes[:'premove']
  end

  if attributes.key?(:'animation')
    self.animation = attributes[:'animation']
  end

  if attributes.key?(:'captured')
    self.captured = attributes[:'captured']
  end

  if attributes.key?(:'follow')
    self.follow = attributes[:'follow']
  end

  if attributes.key?(:'highlight')
    self.highlight = attributes[:'highlight']
  end

  if attributes.key?(:'destination')
    self.destination = attributes[:'destination']
  end

  if attributes.key?(:'coords')
    self.coords = attributes[:'coords']
  end

  if attributes.key?(:'replay')
    self.replay = attributes[:'replay']
  end

  if attributes.key?(:'challenge')
    self.challenge = attributes[:'challenge']
  end

  if attributes.key?(:'message')
    self.message = attributes[:'message']
  end

  if attributes.key?(:'coord_color')
    self.coord_color = attributes[:'coord_color']
  end

  if attributes.key?(:'submit_move')
    self.submit_move = attributes[:'submit_move']
  end

  if attributes.key?(:'confirm_resign')
    self.confirm_resign = attributes[:'confirm_resign']
  end

  if attributes.key?(:'keyboard_move')
    self.keyboard_move = attributes[:'keyboard_move']
  end

  if attributes.key?(:'zen')
    self.zen = attributes[:'zen']
  end

  if attributes.key?(:'move_event')
    self.move_event = attributes[:'move_event']
  end
end

Instance Attribute Details

#animationObject

Returns the value of attribute animation.



44
45
46
# File 'lib/lishogi/models/user_preferences.rb', line 44

def animation
  @animation
end

#bg_imgObject

Returns the value of attribute bg_img.



22
23
24
# File 'lib/lishogi/models/user_preferences.rb', line 22

def bg_img
  @bg_img
end

#blindfoldObject

Returns the value of attribute blindfold.



30
31
32
# File 'lib/lishogi/models/user_preferences.rb', line 30

def blindfold
  @blindfold
end

#capturedObject

Returns the value of attribute captured.



46
47
48
# File 'lib/lishogi/models/user_preferences.rb', line 46

def captured
  @captured
end

#challengeObject

Returns the value of attribute challenge.



58
59
60
# File 'lib/lishogi/models/user_preferences.rb', line 58

def challenge
  @challenge
end

#clock_barObject

Returns the value of attribute clock_bar.



38
39
40
# File 'lib/lishogi/models/user_preferences.rb', line 38

def clock_bar
  @clock_bar
end

#clock_soundObject

Returns the value of attribute clock_sound.



40
41
42
# File 'lib/lishogi/models/user_preferences.rb', line 40

def clock_sound
  @clock_sound
end

#clock_tenthsObject

Returns the value of attribute clock_tenths.



36
37
38
# File 'lib/lishogi/models/user_preferences.rb', line 36

def clock_tenths
  @clock_tenths
end

#confirm_resignObject

Returns the value of attribute confirm_resign.



66
67
68
# File 'lib/lishogi/models/user_preferences.rb', line 66

def confirm_resign
  @confirm_resign
end

#coord_colorObject

Returns the value of attribute coord_color.



62
63
64
# File 'lib/lishogi/models/user_preferences.rb', line 62

def coord_color
  @coord_color
end

#coordsObject

Returns the value of attribute coords.



54
55
56
# File 'lib/lishogi/models/user_preferences.rb', line 54

def coords
  @coords
end

#darkObject

Returns the value of attribute dark.



18
19
20
# File 'lib/lishogi/models/user_preferences.rb', line 18

def dark
  @dark
end

#destinationObject

Returns the value of attribute destination.



52
53
54
# File 'lib/lishogi/models/user_preferences.rb', line 52

def destination
  @destination
end

#followObject

Returns the value of attribute follow.



48
49
50
# File 'lib/lishogi/models/user_preferences.rb', line 48

def follow
  @follow
end

#highlightObject

Returns the value of attribute highlight.



50
51
52
# File 'lib/lishogi/models/user_preferences.rb', line 50

def highlight
  @highlight
end

#keyboard_moveObject

Returns the value of attribute keyboard_move.



68
69
70
# File 'lib/lishogi/models/user_preferences.rb', line 68

def keyboard_move
  @keyboard_move
end

#messageObject

Returns the value of attribute message.



60
61
62
# File 'lib/lishogi/models/user_preferences.rb', line 60

def message
  @message
end

#moretimeObject

Returns the value of attribute moretime.



34
35
36
# File 'lib/lishogi/models/user_preferences.rb', line 34

def moretime
  @moretime
end

#move_eventObject

Returns the value of attribute move_event.



72
73
74
# File 'lib/lishogi/models/user_preferences.rb', line 72

def move_event
  @move_event
end

#piece_setObject

Returns the value of attribute piece_set.



26
27
28
# File 'lib/lishogi/models/user_preferences.rb', line 26

def piece_set
  @piece_set
end

#premoveObject

Returns the value of attribute premove.



42
43
44
# File 'lib/lishogi/models/user_preferences.rb', line 42

def premove
  @premove
end

#replayObject

Returns the value of attribute replay.



56
57
58
# File 'lib/lishogi/models/user_preferences.rb', line 56

def replay
  @replay
end

#sound_setObject

Returns the value of attribute sound_set.



28
29
30
# File 'lib/lishogi/models/user_preferences.rb', line 28

def sound_set
  @sound_set
end

#submit_moveObject

Returns the value of attribute submit_move.



64
65
66
# File 'lib/lishogi/models/user_preferences.rb', line 64

def submit_move
  @submit_move
end

#takebackObject

Returns the value of attribute takeback.



32
33
34
# File 'lib/lishogi/models/user_preferences.rb', line 32

def takeback
  @takeback
end

#themeObject

Returns the value of attribute theme.



24
25
26
# File 'lib/lishogi/models/user_preferences.rb', line 24

def theme
  @theme
end

#transpObject

Returns the value of attribute transp.



20
21
22
# File 'lib/lishogi/models/user_preferences.rb', line 20

def transp
  @transp
end

#zenObject

Returns the value of attribute zen.



70
71
72
# File 'lib/lishogi/models/user_preferences.rb', line 70

def zen
  @zen
end

Class Method Details

._deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
# File 'lib/lishogi/models/user_preferences.rb', line 428

def self._deserialize(type, value)
  case type.to_sym
  when :Time
    Time.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    # models (e.g. Pet) or oneOf
    klass = Lishogi.const_get(type)
    klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
  end
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



131
132
133
# File 'lib/lishogi/models/user_preferences.rb', line 131

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



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
# File 'lib/lishogi/models/user_preferences.rb', line 97

def self.attribute_map
  {
    :'dark' => :'dark',
    :'transp' => :'transp',
    :'bg_img' => :'bgImg',
    :'theme' => :'theme',
    :'piece_set' => :'pieceSet',
    :'sound_set' => :'soundSet',
    :'blindfold' => :'blindfold',
    :'takeback' => :'takeback',
    :'moretime' => :'moretime',
    :'clock_tenths' => :'clockTenths',
    :'clock_bar' => :'clockBar',
    :'clock_sound' => :'clockSound',
    :'premove' => :'premove',
    :'animation' => :'animation',
    :'captured' => :'captured',
    :'follow' => :'follow',
    :'highlight' => :'highlight',
    :'destination' => :'destination',
    :'coords' => :'coords',
    :'replay' => :'replay',
    :'challenge' => :'challenge',
    :'message' => :'message',
    :'coord_color' => :'coordColor',
    :'submit_move' => :'submitMove',
    :'confirm_resign' => :'confirmResign',
    :'keyboard_move' => :'keyboardMove',
    :'zen' => :'zen',
    :'move_event' => :'moveEvent'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
# File 'lib/lishogi/models/user_preferences.rb', line 404

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



170
171
172
173
# File 'lib/lishogi/models/user_preferences.rb', line 170

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



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
162
163
164
165
166
167
# File 'lib/lishogi/models/user_preferences.rb', line 136

def self.openapi_types
  {
    :'dark' => :'Boolean',
    :'transp' => :'Boolean',
    :'bg_img' => :'String',
    :'theme' => :'String',
    :'piece_set' => :'String',
    :'sound_set' => :'String',
    :'blindfold' => :'Integer',
    :'takeback' => :'Integer',
    :'moretime' => :'Integer',
    :'clock_tenths' => :'Integer',
    :'clock_bar' => :'Boolean',
    :'clock_sound' => :'Boolean',
    :'premove' => :'Boolean',
    :'animation' => :'Integer',
    :'captured' => :'Boolean',
    :'follow' => :'Boolean',
    :'highlight' => :'Boolean',
    :'destination' => :'Boolean',
    :'coords' => :'Integer',
    :'replay' => :'Integer',
    :'challenge' => :'Integer',
    :'message' => :'Integer',
    :'coord_color' => :'Integer',
    :'submit_move' => :'Integer',
    :'confirm_resign' => :'Integer',
    :'keyboard_move' => :'Integer',
    :'zen' => :'Integer',
    :'move_event' => :'Integer'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
# File 'lib/lishogi/models/user_preferences.rb', line 356

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      dark == o.dark &&
      transp == o.transp &&
      bg_img == o.bg_img &&
      theme == o.theme &&
      piece_set == o.piece_set &&
      sound_set == o.sound_set &&
      blindfold == o.blindfold &&
      takeback == o.takeback &&
      moretime == o.moretime &&
      clock_tenths == o.clock_tenths &&
      clock_bar == o.clock_bar &&
      clock_sound == o.clock_sound &&
      premove == o.premove &&
      animation == o.animation &&
      captured == o.captured &&
      follow == o.follow &&
      highlight == o.highlight &&
      destination == o.destination &&
      coords == o.coords &&
      replay == o.replay &&
      challenge == o.challenge &&
      message == o.message &&
      coord_color == o.coord_color &&
      submit_move == o.submit_move &&
      confirm_resign == o.confirm_resign &&
      keyboard_move == o.keyboard_move &&
      zen == o.zen &&
      move_event == o.move_event
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



499
500
501
502
503
504
505
506
507
508
509
510
511
# File 'lib/lishogi/models/user_preferences.rb', line 499

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


391
392
393
# File 'lib/lishogi/models/user_preferences.rb', line 391

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



397
398
399
# File 'lib/lishogi/models/user_preferences.rb', line 397

def hash
  [dark, transp, bg_img, theme, piece_set, sound_set, blindfold, takeback, moretime, clock_tenths, clock_bar, clock_sound, premove, animation, captured, follow, highlight, destination, coords, replay, challenge, message, coord_color, submit_move, confirm_resign, keyboard_move, zen, move_event].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



305
306
307
308
309
# File 'lib/lishogi/models/user_preferences.rb', line 305

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



475
476
477
# File 'lib/lishogi/models/user_preferences.rb', line 475

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



481
482
483
484
485
486
487
488
489
490
491
492
493
# File 'lib/lishogi/models/user_preferences.rb', line 481

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



469
470
471
# File 'lib/lishogi/models/user_preferences.rb', line 469

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



313
314
315
316
317
318
319
320
321
322
# File 'lib/lishogi/models/user_preferences.rb', line 313

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  theme_validator = EnumAttributeValidator.new('String', ["orange", "natural", "wood", "wood1", "kaya1", "kaya2", "oak", "blue", "grey", "painting1", "painting2", "kinkaku", "space", "dobutsu", "custom"])
  return false unless theme_validator.valid?(@theme)
  piece_set_validator = EnumAttributeValidator.new('String', ["kanji_light", "kanji_brown", "Ryoko_1Kanji", "orangain", "kanji_red_wood", "Portella", "Portella_2Kanji", "1Kanji_3D", "2Kanji_3D", "Shogi_cz", "Engraved_cz", "Kanji_Guide_Shadowed", "Valdivia", "Vald_opt", "pixel", "shogi_BnW", "Intl_Colored_2D", "Intl_Colored_3D", "Intl_Shadowed", "Intl_Monochrome_2D", "Intl_Wooden_3D", "Intl_Portella", "international", "simple_kanji", "doubutsu", "Logy_Games", "western"])
  return false unless piece_set_validator.valid?(@piece_set)
  sound_set_validator = EnumAttributeValidator.new('String', ["silent", "chess", "nes", "sfx", "futuristic", "robot", "music", "shogiAlt", "shogi", "speech"])
  return false unless sound_set_validator.valid?(@sound_set)
  true
end