class TVTid::Program

Attributes

category[RW]

@return [String] the category of the program.

channel_id[RW]

@return [Numeric] the ID of the channel.

description[RW]

@return [String] the description of the program.

id[R]

@return [Numeric] the id of the program.

original_title[RW]

@return [String] the original non-localized title of the program.

production_country[RW]

@return [String] the production country of the program.

production_year[RW]

@return [Numeric] the year of production of the program.

series_id[RW]

@return [Numeric] a unique series id if the program is a series.

series_info[RW]

@return [Hash, nil] episode and season information if the program is a

series.
start_time[RW]

@return [DateTime] the time the program starts at.

stop_time[RW]

@return [DateTime] the time the program ends at.

teaser[RW]

@return [String] the teaser text of the program.

title[R]

@return [String] the title of the program.

url[RW]

@return [String] a URL to where the user can see more information about

the program.

Public Class Methods

from_json(json) click to toggle source

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
new(id, title) click to toggle source

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

parse_json!(json) click to toggle source

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