Class: APDM::DesignElements

Inherits:
Object
  • Object
show all
Defined in:
lib/apdm/design_elements.rb,
lib/apdm/design_elements/api.rb

Defined Under Namespace

Classes: API

Constant Summary collapse

VERSION =
4
ONE_DAY =
60 * 60 * 24
HOST =

…/v4/… returns a 404

"http://r.api.no/local/v3/publications/"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(channel, options = {}) ⇒ DesignElements

Returns a new instance of DesignElements.



11
12
13
14
# File 'lib/apdm/design_elements.rb', line 11

def initialize(channel, options = {})
  @api_key = options[:api_key]
  @channel = Channel.find(channel)
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



10
11
12
# File 'lib/apdm/design_elements.rb', line 10

def api_key
  @api_key
end

#channelObject (readonly)

Returns the value of attribute channel.



10
11
12
# File 'lib/apdm/design_elements.rb', line 10

def channel
  @channel
end

Instance Method Details

#apiObject



16
17
18
# File 'lib/apdm/design_elements.rb', line 16

def api
  @api ||= API.new(channel.homepage, :api_key => api_key)
end

#cssObject



32
33
34
35
36
# File 'lib/apdm/design_elements.rb', line 32

def css
  cached('css') do
    api.fetch_css
  end
end


26
27
28
29
30
# File 'lib/apdm/design_elements.rb', line 26

def footer
  cached('footer') do
    api.fetch_html('footer')
  end
end

#headerObject



20
21
22
23
24
# File 'lib/apdm/design_elements.rb', line 20

def header
  cached('header') do
    api.fetch_html('slimTop')
  end
end

#site_stat(category = 'PLACEHOLDER') ⇒ Object



38
39
40
41
42
# File 'lib/apdm/design_elements.rb', line 38

def site_stat(category = 'PLACEHOLDER')
  cached("site_stat.#{category}") do
    api.fetch_site_stat(category)
  end
end