Class: APDM::DesignElements
- Inherits:
-
Object
- Object
- APDM::DesignElements
- 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
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
Instance Method Summary collapse
- #api ⇒ Object
- #css ⇒ Object
- #footer ⇒ Object
- #header ⇒ Object
-
#initialize(channel, options = {}) ⇒ DesignElements
constructor
A new instance of DesignElements.
- #site_stat(category = 'PLACEHOLDER') ⇒ Object
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, = {}) @api_key = [:api_key] @channel = Channel.find(channel) end |
Instance Attribute Details
#api_key ⇒ Object (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 |
#channel ⇒ Object (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
#api ⇒ Object
16 17 18 |
# File 'lib/apdm/design_elements.rb', line 16 def api @api ||= API.new(channel.homepage, :api_key => api_key) end |
#css ⇒ Object
32 33 34 35 36 |
# File 'lib/apdm/design_elements.rb', line 32 def css cached('css') do api.fetch_css end end |
#footer ⇒ Object
26 27 28 29 30 |
# File 'lib/apdm/design_elements.rb', line 26 def cached('footer') do api.fetch_html('footer') end end |
#header ⇒ Object
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 |