class TVTid::Program
Attributes
@return [String] the category of the program.
@return [Numeric] the ID of the channel.
@return [String] the description of the program.
@return [Numeric] the id of the program.
@return [String] the original non-localized title of the program.
@return [String] the production country of the program.
@return [Numeric] the year of production of the program.
@return [Numeric] a unique series id if the program is a series.
@return [Hash, nil] episode and season information if the program is a
series.
@return [DateTime] the time the program starts at.
@return [DateTime] the time the program ends at.
@return [String] the title of the program.
@return [String] a URL to where the user can see more information about
the program.
Public Class Methods
Constructs a `Program` from a json object.
@param json [Hash] Parsed JSON object @return [Program, nil] program if the given `json` object has an `id`
and a `title` attribute, nil otherwise.
# 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
Constructs a new `Program` with an `id` and a `title`.
# File library/tvtid/program.rb, line 35 def initialize id, title @id = id @title = title end
Public Instance Methods
Updates the program information from a json object.
@param json [Hash] Parsed JSON object
# 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') @teaser = json['teaser'] if json.key?('teaser') @series_id = json['series_id'] if json.key?('seriesId') @series_info = json['series'] if json.key?('series') end