Class: APDM::AdTech::AdLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/apdm/ad_tech/ad_loader.rb

Constant Summary collapse

APDM_NETWORK_ID =
1361.1
KAMPANJE_NETWORK_ID =
893.1

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ AdLoader

Returns a new instance of AdLoader.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/apdm/ad_tech/ad_loader.rb', line 9

def initialize(options)
  @dom_prefix = "ad_tech_loader_#{SecureRandom.random_number(2 ** 64).to_s(36)}"
  @network_id = options[:channel_name] == "Kampanje" ? KAMPANJE_NETWORK_ID : APDM_NETWORK_ID
  @key = options[:key]
  @context_key = options[:context_key]
  @placement_name = options[:placement_name]
  @placement_id = options[:placement_id]
  @dimensions_id = options[:dimensions_id]
  @height = options[:height]
  @width = options[:width]
  @channel_name = options[:channel_name]
  @group_id = options[:group_id]
end

Instance Attribute Details

#channel_nameObject (readonly)

Returns the value of attribute channel_name.



8
9
10
# File 'lib/apdm/ad_tech/ad_loader.rb', line 8

def channel_name
  @channel_name
end

#context_keyObject (readonly)

Returns the value of attribute context_key.



8
9
10
# File 'lib/apdm/ad_tech/ad_loader.rb', line 8

def context_key
  @context_key
end

#dimensions_idObject (readonly)

Returns the value of attribute dimensions_id.



8
9
10
# File 'lib/apdm/ad_tech/ad_loader.rb', line 8

def dimensions_id
  @dimensions_id
end

#dom_prefixObject (readonly)

Returns the value of attribute dom_prefix.



8
9
10
# File 'lib/apdm/ad_tech/ad_loader.rb', line 8

def dom_prefix
  @dom_prefix
end

#group_idObject (readonly)

Returns the value of attribute group_id.



8
9
10
# File 'lib/apdm/ad_tech/ad_loader.rb', line 8

def group_id
  @group_id
end

#heightObject (readonly)

Returns the value of attribute height.



8
9
10
# File 'lib/apdm/ad_tech/ad_loader.rb', line 8

def height
  @height
end

#keyObject (readonly)

Returns the value of attribute key.



8
9
10
# File 'lib/apdm/ad_tech/ad_loader.rb', line 8

def key
  @key
end

#network_idObject (readonly)

Returns the value of attribute network_id.



8
9
10
# File 'lib/apdm/ad_tech/ad_loader.rb', line 8

def network_id
  @network_id
end

#placement_idObject (readonly)

Returns the value of attribute placement_id.



8
9
10
# File 'lib/apdm/ad_tech/ad_loader.rb', line 8

def placement_id
  @placement_id
end

#placement_nameObject (readonly)

Returns the value of attribute placement_name.



8
9
10
# File 'lib/apdm/ad_tech/ad_loader.rb', line 8

def placement_name
  @placement_name
end

#widthObject (readonly)

Returns the value of attribute width.



8
9
10
# File 'lib/apdm/ad_tech/ad_loader.rb', line 8

def width
  @width
end

Instance Method Details

#to_sObject



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/apdm/ad_tech/ad_loader.rb', line 23

def to_s
  <<-ADSTRING.gsub(/^\s{10}/, '')
    #{start_ad_tech_loader}
      <script>
        document.write('<scr'+'ipt language="javascript1.1" src="#{url('addyn', 100)};misc='+new Date().getTime()+'"></scri'+'pt>');
      </script>
      <noscript>
        <a href="#{url('adlink', 300, '')}" target="_blank">
          <img src="#{url('adserv', 300, '')}" border="0" width="#{width}" height="#{height}">
        </a>
      </noscript>
ADSTRING
end