Class: One40Proof::Ad
- Inherits:
-
Object
- Object
- One40Proof::Ad
- Defined in:
- lib/one40_proof/attributes/ad.rb
Instance Method Summary collapse
- #action_urls ⇒ Object
-
#byline ⇒ Object
e.g “ads by Pizza Hut”.
- #image_url ⇒ Object
-
#initialize(data) ⇒ Ad
constructor
A new instance of Ad.
- #status ⇒ Object
-
#text ⇒ Object
Ad text.
- #user ⇒ Object
-
#validate_impression! ⇒ Object
The ad’s impression_url must be requested (using the GET method) when an ad unit is displayed (for verification purposes).
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_urls ⇒ Object
32 33 34 |
# File 'lib/one40_proof/attributes/ad.rb', line 32 def action_urls @action_urls ||= ActionUrls.new(@data['action_urls']) end |
#byline ⇒ Object
e.g “ads by Pizza Hut”
19 20 21 |
# File 'lib/one40_proof/attributes/ad.rb', line 19 def @data['byline'] end |
#image_url ⇒ Object
14 15 16 |
# File 'lib/one40_proof/attributes/ad.rb', line 14 def image_url @data['image_url'] end |
#status ⇒ Object
36 37 38 |
# File 'lib/one40_proof/attributes/ad.rb', line 36 def status @status ||= Status.new(@data['status']) end |
#text ⇒ Object
Ad text
24 25 26 |
# File 'lib/one40_proof/attributes/ad.rb', line 24 def text @data['text'] end |
#user ⇒ Object
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 |