Class: FilmOn::Genre

Inherits:
Object
  • Object
show all
Defined in:
lib/film_on/models/genre.rb

Overview

Genre is a group of movies bundled together such as “Sports” or “Horror” takes a raw hash and converts it into a nice ruby object

Defined Under Namespace

Classes: Image

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Genre

Returns a new instance of Genre.



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/film_on/models/genre.rb', line 16

def initialize(hash)
  @id = hash["id"]
  @vendorka_id = hash["vendorka_id"]
  @name = hash["name"]
  @slug = hash["slug"]
  @position = hash["position"]
  @content_count = hash["content_count"]
  @updated_at = hash["updated_at"]
  @description = hash["description"]
  @images = get_images(hash["images"])
end

Instance Attribute Details

#content_countObject (readonly)

Returns the value of attribute content_count.



13
14
15
# File 'lib/film_on/models/genre.rb', line 13

def content_count
  @content_count
end

#descriptionObject (readonly)

Returns the value of attribute description.



13
14
15
# File 'lib/film_on/models/genre.rb', line 13

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



12
13
14
# File 'lib/film_on/models/genre.rb', line 12

def id
  @id
end

#imagesObject (readonly)

Returns the value of attribute images.



13
14
15
# File 'lib/film_on/models/genre.rb', line 13

def images
  @images
end

#nameObject (readonly)

Returns the value of attribute name.



12
13
14
# File 'lib/film_on/models/genre.rb', line 12

def name
  @name
end

#positionObject (readonly)

Returns the value of attribute position.



12
13
14
# File 'lib/film_on/models/genre.rb', line 12

def position
  @position
end

#retina_imageObject (readonly)

Returns the value of attribute retina_image.



14
15
16
# File 'lib/film_on/models/genre.rb', line 14

def retina_image
  @retina_image
end

#slugObject (readonly)

Returns the value of attribute slug.



12
13
14
# File 'lib/film_on/models/genre.rb', line 12

def slug
  @slug
end

#standard_imageObject (readonly)

Returns the value of attribute standard_image.



14
15
16
# File 'lib/film_on/models/genre.rb', line 14

def standard_image
  @standard_image
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



13
14
15
# File 'lib/film_on/models/genre.rb', line 13

def updated_at
  @updated_at
end

#vendorka_idObject (readonly)

Returns the value of attribute vendorka_id.



12
13
14
# File 'lib/film_on/models/genre.rb', line 12

def vendorka_id
  @vendorka_id
end

Instance Method Details

#get_images(imgs) ⇒ Object



36
37
38
39
# File 'lib/film_on/models/genre.rb', line 36

def get_images(imgs)
  return [] unless imgs.is_a?(Array)
  imgs.map{|img| Image.new(img["type"], img["width"], img["height"], img["url"]) }
end