Method: Kuapir::FilmTopResponse#initialize

Defined in:
lib/kuapir/models/film_top_response.rb

#initialize(attributes = {}) ⇒ FilmTopResponse

Initializes the object

Parameters:

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

    Model attributes in the form of hash



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/kuapir/models/film_top_response.rb', line 38

def initialize(attributes = {})
  unless attributes.is_a?(Hash)
    raise ArgumentError,
          "The input argument (attributes) must be a hash in `Kuapir::FilmTopResponse` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) do |(k, v), h|
    unless self.class.attribute_map.key?(k.to_sym)
      raise ArgumentError,
            "`#{k}` is not a valid attribute in `Kuapir::FilmTopResponse`. 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
  end

  self.pages_count = attributes[:pages_count] if attributes.key?(:pages_count)

  if attributes.key?(:films) && (value = attributes[:films]).is_a?(Array)
    self.films = value
  end
end