Class: FilmOn::Movie

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

Overview

FilmOn::Movie Movie can have either a basic set of data or a more verbose set depending on whether it is called as part of a vod_search or as in individual call from #movie, 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) ⇒ Movie

Returns a new instance of Movie.



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
# File 'lib/film_on/models/movie.rb', line 18

def initialize(hash)
  @id = hash["id"]
  @title = hash["title"]
  @slug = hash["slug"]
  @description = hash["description"]
  @type_id = hash["type_id"]
  @series_number = hash["series_number"]
  @episode_number = hash["episode_number"]
  @episodes_count = hash["episodes_count"]
  @episodes = hash["episodes"]
  @vendor_id = hash["vendor_id"]
  @vendorka_id = hash["vendorka_id"]
  @content_host = hash["content_host"]
  @low_quality_file_id = hash["low_quality_file_id"]
  @high_quality_file_id = hash["high_quality_file_id"]
  @parent_id = hash["parent_id"]
  @exists_on_edgecast = hash["exists_on_edgecast"]
  @is_featured = hash["is_featured"]
  @is_enabled = hash["is_enabled"]
  @deleted_at = hash["deleted_at"]
  @genres = hash["genres"]
  @cast = hash["cast"]
  @crew = hash["crew"]
  @artwork = hash["artwork"] #TODO convert to image structs
  @poster = hash["poster"]
  @poster_small = get_image(:small, hash["poster"])
  @poster_medium = get_image(:medium, hash["poster"])
  @poster_large = get_image(:large, hash["poster"])
  @georule = hash["georule"]
  @type = hash["type"]
  @streams = hash["streams"]
  @content_blocked = hash["content_blocked"]
end

Instance Attribute Details

#artworkObject (readonly)

Returns the value of attribute artwork.



15
16
17
# File 'lib/film_on/models/movie.rb', line 15

def artwork
  @artwork
end

#castObject (readonly)

Returns the value of attribute cast.



15
16
17
# File 'lib/film_on/models/movie.rb', line 15

def cast
  @cast
end

#content_blockedObject (readonly)

Returns the value of attribute content_blocked.



16
17
18
# File 'lib/film_on/models/movie.rb', line 16

def content_blocked
  @content_blocked
end

#content_hostObject (readonly)

Returns the value of attribute content_host.



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

def content_host
  @content_host
end

#crewObject (readonly)

Returns the value of attribute crew.



15
16
17
# File 'lib/film_on/models/movie.rb', line 15

def crew
  @crew
end

#deleted_atObject (readonly)

Returns the value of attribute deleted_at.



15
16
17
# File 'lib/film_on/models/movie.rb', line 15

def deleted_at
  @deleted_at
end

#descriptionObject (readonly)

Returns the value of attribute description.



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

def description
  @description
end

#episodes_countObject (readonly)

Returns the value of attribute episodes_count.



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

def episodes_count
  @episodes_count
end

#exists_on_edgecastObject (readonly)

Returns the value of attribute exists_on_edgecast.



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

def exists_on_edgecast
  @exists_on_edgecast
end

#genresObject (readonly)

Returns the value of attribute genres.



15
16
17
# File 'lib/film_on/models/movie.rb', line 15

def genres
  @genres
end

#georuleObject (readonly)

Returns the value of attribute georule.



15
16
17
# File 'lib/film_on/models/movie.rb', line 15

def georule
  @georule
end

#high_quality_file_idObject (readonly)

Returns the value of attribute high_quality_file_id.



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

def high_quality_file_id
  @high_quality_file_id
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#is_enabledObject (readonly)

Returns the value of attribute is_enabled.



15
16
17
# File 'lib/film_on/models/movie.rb', line 15

def is_enabled
  @is_enabled
end

Returns the value of attribute is_featured.



15
16
17
# File 'lib/film_on/models/movie.rb', line 15

def is_featured
  @is_featured
end

#low_quality_file_idObject (readonly)

Returns the value of attribute low_quality_file_id.



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

def low_quality_file_id
  @low_quality_file_id
end

#parent_idObject (readonly)

Returns the value of attribute parent_id.



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

def parent_id
  @parent_id
end

#posterObject (readonly)

Returns the value of attribute poster.



15
16
17
# File 'lib/film_on/models/movie.rb', line 15

def poster
  @poster
end

#poster_largeObject (readonly)

Returns the value of attribute poster_large.



16
17
18
# File 'lib/film_on/models/movie.rb', line 16

def poster_large
  @poster_large
end

#poster_mediumObject (readonly)

Returns the value of attribute poster_medium.



16
17
18
# File 'lib/film_on/models/movie.rb', line 16

def poster_medium
  @poster_medium
end

#poster_smallObject (readonly)

Returns the value of attribute poster_small.



16
17
18
# File 'lib/film_on/models/movie.rb', line 16

def poster_small
  @poster_small
end

#series_numberObject (readonly)

Returns the value of attribute series_number.



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

def series_number
  @series_number
end

#slugObject (readonly)

Returns the value of attribute slug.



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

def slug
  @slug
end

#streamsObject (readonly)

Returns the value of attribute streams.



16
17
18
# File 'lib/film_on/models/movie.rb', line 16

def streams
  @streams
end

#titleObject (readonly)

Returns the value of attribute title.



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

def title
  @title
end

#typeObject (readonly)

Returns the value of attribute type.



15
16
17
# File 'lib/film_on/models/movie.rb', line 15

def type
  @type
end

#type_idObject (readonly)

Returns the value of attribute type_id.



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

def type_id
  @type_id
end

#vendor_idObject (readonly)

Returns the value of attribute vendor_id.



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

def vendor_id
  @vendor_id
end

#vendorka_idObject (readonly)

Returns the value of attribute vendorka_id.



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

def vendorka_id
  @vendorka_id
end

Instance Method Details

#get_image(type, image) ⇒ Object



52
53
54
55
56
57
58
59
60
61
# File 'lib/film_on/models/movie.rb', line 52

def get_image(type, image)
  return {} unless image.is_a?(Hash)
  case type
  when :small
    image = (image["thumbs"] && image["thumbs"]["thumb_120p"]) ? image["thumbs"]["thumb_120p"] : image
  when :medium
    image = (image["thumbs"] && image["thumbs"]["thumb_220p"]) ? image["thumbs"]["thumb_220p"] : image
  end
  Image.new(image["type"], image["width"], image["height"], image["url"])
end