Class: One40Proof::Ad

Inherits:
Object
  • Object
show all
Defined in:
lib/one40_proof/attributes/ad.rb

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Ad

Returns a new instance of Ad.



10
11
12
# File 'lib/one40_proof/attributes/ad.rb', line 10

def initialize(data)
  @data = JSON.parse(data)['ads'][0]
end

Instance Method Details

#action_urlsObject



32
33
34
# File 'lib/one40_proof/attributes/ad.rb', line 32

def action_urls
  @action_urls ||= ActionUrls.new(@data['action_urls'])
end

#bylineObject

e.g “ads by Pizza Hut”



19
20
21
# File 'lib/one40_proof/attributes/ad.rb', line 19

def 
  @data['byline']
end

#image_urlObject



14
15
16
# File 'lib/one40_proof/attributes/ad.rb', line 14

def image_url
  @data['image_url']
end

#statusObject



36
37
38
# File 'lib/one40_proof/attributes/ad.rb', line 36

def status
  @status ||= Status.new(@data['status'])
end

#textObject

Ad text



24
25
26
# File 'lib/one40_proof/attributes/ad.rb', line 24

def text
  @data['text']
end

#userObject



28
29
30
# File 'lib/one40_proof/attributes/ad.rb', line 28

def user
  @user ||= User.new(@data['user'])
end

#validate_impression!Object

The ad’s impression_url must be requested (using the GET method) when an ad unit is displayed (for verification purposes).



41
42
43
# File 'lib/one40_proof/attributes/ad.rb', line 41

def validate_impression!
  Net::HTTP.get(URI.parse(action_urls.impression_url))
end