Class: FilmOn::Programme

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

Overview

Programme holds the detail of a TV programme, it 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) ⇒ Programme

Returns a new instance of Programme.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/film_on/models/programme.rb', line 13

def initialize(hash)
  @programme = hash["programme"]
  @startdatetime = hash["startdatetime"]
  @enddatetime = hash["enddatetime"]
  @duration = hash["duration"]
  @length = hash["length"]
  @programme_description = hash["programme_description"]
  @programme_name = hash["programme_name"]
  @allow_dvr = hash["allow_dvr"]
  @allow_reminder = hash["allow_reminder"]
  @channel_id = hash["channel_id"]
  @images = get_images(hash["images"])
  @provider = hash["provider"]
  @vendor_id = hash["vendor_id"]
  @series_number = hash["seriesNumber"]
  @episode_number = hash["episodeNumber"]
  @series_id = hash["seriesId"]
  @is_series = hash["isSeries"]
end

Instance Attribute Details

#allow_dvrObject (readonly)

Returns the value of attribute allow_dvr.



10
11
12
# File 'lib/film_on/models/programme.rb', line 10

def allow_dvr
  @allow_dvr
end

#allow_reminderObject (readonly)

Returns the value of attribute allow_reminder.



11
12
13
# File 'lib/film_on/models/programme.rb', line 11

def allow_reminder
  @allow_reminder
end

#channel_idObject (readonly)

Returns the value of attribute channel_id.



11
12
13
# File 'lib/film_on/models/programme.rb', line 11

def channel_id
  @channel_id
end

#durationObject (readonly)

Returns the value of attribute duration.



10
11
12
# File 'lib/film_on/models/programme.rb', line 10

def duration
  @duration
end

#enddatetimeObject (readonly)

Returns the value of attribute enddatetime.



10
11
12
# File 'lib/film_on/models/programme.rb', line 10

def enddatetime
  @enddatetime
end

#episode_numberObject (readonly)

Returns the value of attribute episode_number.



11
12
13
# File 'lib/film_on/models/programme.rb', line 11

def episode_number
  @episode_number
end

#imagesObject (readonly)

Returns the value of attribute images.



11
12
13
# File 'lib/film_on/models/programme.rb', line 11

def images
  @images
end

#is_seriesObject (readonly)

Returns the value of attribute is_series.



11
12
13
# File 'lib/film_on/models/programme.rb', line 11

def is_series
  @is_series
end

#lengthObject (readonly)

Returns the value of attribute length.



10
11
12
# File 'lib/film_on/models/programme.rb', line 10

def length
  @length
end

#programmeObject (readonly)

Returns the value of attribute programme.



10
11
12
# File 'lib/film_on/models/programme.rb', line 10

def programme
  @programme
end

#programme_descriptionObject (readonly)

Returns the value of attribute programme_description.



10
11
12
# File 'lib/film_on/models/programme.rb', line 10

def programme_description
  @programme_description
end

#programme_nameObject (readonly)

Returns the value of attribute programme_name.



10
11
12
# File 'lib/film_on/models/programme.rb', line 10

def programme_name
  @programme_name
end

#providerObject (readonly)

Returns the value of attribute provider.



11
12
13
# File 'lib/film_on/models/programme.rb', line 11

def provider
  @provider
end

#series_idObject (readonly)

Returns the value of attribute series_id.



11
12
13
# File 'lib/film_on/models/programme.rb', line 11

def series_id
  @series_id
end

#series_numberObject (readonly)

Returns the value of attribute series_number.



11
12
13
# File 'lib/film_on/models/programme.rb', line 11

def series_number
  @series_number
end

#startdatetimeObject (readonly)

Returns the value of attribute startdatetime.



10
11
12
# File 'lib/film_on/models/programme.rb', line 10

def startdatetime
  @startdatetime
end

#vendor_idObject (readonly)

Returns the value of attribute vendor_id.



11
12
13
# File 'lib/film_on/models/programme.rb', line 11

def vendor_id
  @vendor_id
end

Instance Method Details

#get_images(imgs) ⇒ Object



33
34
35
36
# File 'lib/film_on/models/programme.rb', line 33

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