Class: Enklawa::Api::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/enklawa/api/request.rb

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Request



7
8
9
10
11
12
13
14
15
16
# File 'lib/enklawa/api/request.rb', line 7

def initialize(url)
  @info_xml_url  = File.join([url, "info.xml"])
  @main_page_url = url
  @cache_key     = url.gsub(/[^a-z]/i,"") + ".yml"
  @cache = YAML::load_file(@cache_key) if File.exists?(@cache_key)
  @cache ||= {
    'images' => {},
    'durations' => {}
  }
end

Instance Method Details

#get!Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/enklawa/api/request.rb', line 18

def get!
  @response = Response.new
  get_info!
  get_programs!
  get_episodes!

  File.open(@cache_key, 'w') {|f| f.write @cache.to_yaml }

  @response
end