Module: TheTvdb

Defined in:
lib/the_tvdb.rb,
lib/the_tvdb/show.rb,
lib/the_tvdb/episode.rb,
lib/the_tvdb/gateway.rb,
lib/the_tvdb/version.rb,
lib/the_tvdb/configuration.rb,
lib/generators/the_tvdb/install_generator.rb

Defined Under Namespace

Modules: Generators Classes: Configuration, Episode, Gateway, Show

Constant Summary collapse

VERSION =
"0.1.5"

Class Method Summary collapse

Class Method Details

.configurationObject



13
14
15
# File 'lib/the_tvdb.rb', line 13

def self.configuration
  @config ||= Configuration.instance
end

.gatewayObject



17
18
19
# File 'lib/the_tvdb.rb', line 17

def self.gateway
  @gateway ||= Gateway.instance
end

.setup {|self.configuration| ... } ⇒ Object

Yields:



9
10
11
# File 'lib/the_tvdb.rb', line 9

def self.setup
  yield self.configuration
end

.update(timestamp = nil, full_data = false) ⇒ Hash

Starting from the last update recorded on the gateway, a hash with the new update time and the updated shows are returned

Parameters:

  • timestamp (Integer) (defaults to: nil)

    the last update timestamp (if not provided the last_updated attribute of Gateway is used instead)

  • full_data (Boolean) (defaults to: false)

    if set to true will return full Show and Episode objects, not just the ids (defaults to false)

Returns:

  • (Hash)

    the new last_updated time and the Shows that have been updated or their ids



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/the_tvdb.rb', line 27

def self.update(timestamp=nil, full_data=false)
  update_hash = gateway.update(timestamp)
  result = { time: update_hash['Time'].to_i }
  result[:shows] = []
  if update_hash['Series']
    if full_data
      result[:shows] = update_hash['Series'].map {|show_remote_id| Show.find(show_remote_id) }
    else
      result[:shows] = update_hash['Series'].map {|show_remote_id| show_remote_id.to_i }
    end
  end
  gateway.last_updated = result[:time]
  result
end