Class: TVTid::Program
- Inherits:
-
Object
- Object
- TVTid::Program
- Defined in:
- library/tvtid/program.rb
Instance Attribute Summary collapse
-
#category ⇒ String
The category of the program.
-
#channel_id ⇒ Numeric
The ID of the channel.
-
#description ⇒ String
The description of the program.
-
#id ⇒ Numeric
readonly
The id of the program.
-
#original_title ⇒ String
The original non-localized title of the program.
-
#production_country ⇒ String
The production country of the program.
-
#production_year ⇒ Numeric
The year of production of the program.
-
#series_id ⇒ Numeric
A unique series id if the program is a series.
-
#series_info ⇒ Hash?
Episode and season information if the program is a series.
-
#start_time ⇒ DateTime
The time the program starts at.
-
#stop_time ⇒ DateTime
The time the program ends at.
-
#teaser ⇒ String
The teaser text of the program.
-
#title ⇒ String
readonly
The title of the program.
-
#url ⇒ String
A URL to where the user can see more information about the program.
Class Method Summary collapse
-
.from_json(json) ⇒ Program?
Constructs a ‘Program` from a json object.
Instance Method Summary collapse
-
#initialize(id, title) ⇒ Program
constructor
Constructs a new ‘Program` with an `id` and a `title`.
-
#parse_json!(json) ⇒ Object
Updates the program information from a json object.
Constructor Details
#initialize(id, title) ⇒ Program
Constructs a new ‘Program` with an `id` and a `title`.
35 36 37 38 |
# File 'library/tvtid/program.rb', line 35 def initialize id, title @id = id @title = title end |
Instance Attribute Details
#category ⇒ String
Returns the category of the program.
17 18 19 |
# File 'library/tvtid/program.rb', line 17 def category @category end |
#channel_id ⇒ Numeric
Returns the ID of the channel.
15 16 17 |
# File 'library/tvtid/program.rb', line 15 def channel_id @channel_id end |
#description ⇒ String
Returns the description of the program.
19 20 21 |
# File 'library/tvtid/program.rb', line 19 def description @description end |
#id ⇒ Numeric (readonly)
Returns the id of the program.
4 5 6 |
# File 'library/tvtid/program.rb', line 4 def id @id end |
#original_title ⇒ String
Returns the original non-localized title of the program.
21 22 23 |
# File 'library/tvtid/program.rb', line 21 def original_title @original_title end |
#production_country ⇒ String
Returns the production country of the program.
25 26 27 |
# File 'library/tvtid/program.rb', line 25 def production_country @production_country end |
#production_year ⇒ Numeric
Returns the year of production of the program.
23 24 25 |
# File 'library/tvtid/program.rb', line 23 def production_year @production_year end |
#series_id ⇒ Numeric
Returns a unique series id if the program is a series.
29 30 31 |
# File 'library/tvtid/program.rb', line 29 def series_id @series_id end |
#series_info ⇒ Hash?
Returns episode and season information if the program is a series.
32 33 34 |
# File 'library/tvtid/program.rb', line 32 def series_info @series_info end |
#start_time ⇒ DateTime
Returns the time the program starts at.
8 9 10 |
# File 'library/tvtid/program.rb', line 8 def start_time @start_time end |
#stop_time ⇒ DateTime
Returns the time the program ends at.
10 11 12 |
# File 'library/tvtid/program.rb', line 10 def stop_time @stop_time end |
#teaser ⇒ String
Returns the teaser text of the program.
27 28 29 |
# File 'library/tvtid/program.rb', line 27 def end |
#title ⇒ String (readonly)
Returns the title of the program.
6 7 8 |
# File 'library/tvtid/program.rb', line 6 def title @title end |
#url ⇒ String
Returns a URL to where the user can see more information about the program.
13 14 15 |
# File 'library/tvtid/program.rb', line 13 def url @url end |
Class Method Details
.from_json(json) ⇒ Program?
Constructs a ‘Program` from a json object.
62 63 64 65 66 67 68 |
# File 'library/tvtid/program.rb', line 62 def self.from_json json return nil unless json['id'] and json['title'] Program.new(json['id'], json['title']).tap do |program| program.parse_json! json end end |
Instance Method Details
#parse_json!(json) ⇒ Object
Updates the program information from a json object.
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'library/tvtid/program.rb', line 43 def parse_json! json @start_time = Time.at(json['start']).to_datetime @stop_time = Time.at(json['stop']).to_datetime @url = json['url'] if json.key?('url') @channel_id = json['channelId'] if json.key?('channelId') @category = json['category'] if json.key?('category') @description = json['desc'] if json.key?('desc') @production_year = json['prodYear'] if json.key?('prodYear') @production_country = json['prodCountry'] if json.key?('prodCountry') = json['teaser'] if json.key?('teaser') @series_id = json['series_id'] if json.key?('seriesId') @series_info = json['series'] if json.key?('series') end |