Class: OpenX::TargetingRules

Inherits:
Array
  • Object
show all
Defined in:
lib/openx/targeting_rules.rb

Overview

Create targeting rule sets. Example:

rules = OpenX::TargetingRules.new do |t|
  t['Site:Pageurl'].include?('test') &
  t['Client:Ip'].match?(/^127\./) |
  t['Geo:Country'].include?('GB', 'US')
end

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ TargetingRules

Returns a new instance of TargetingRules.



12
13
14
15
# File 'lib/openx/targeting_rules.rb', line 12

def initialize(&block)
  super([])
  block.call(self)
end

Instance Method Details

#[](key) ⇒ Object



17
18
19
20
21
# File 'lib/openx/targeting_rules.rb', line 17

def [](key)
  rule = TargetingRule.new(key)
  push(rule)
  rule
end