Class: GScraper::SponsoredAd
- Inherits:
-
Object
- Object
- GScraper::SponsoredAd
- Defined in:
- lib/gscraper/sponsored_ad.rb
Instance Attribute Summary collapse
-
#title ⇒ Object
readonly
Title of the ad.
-
#url ⇒ Object
readonly
URL of the ad.
Instance Method Summary collapse
-
#direct_link ⇒ String
The direct link of the ad.
-
#direct_url ⇒ URI::HTTP
The direct URI of the ad.
-
#initialize(title, url) ⇒ SponsoredAd
constructor
Creates a new SponsoredAd.
-
#to_s ⇒ String
The title of the ad.
Constructor Details
#initialize(title, url) ⇒ SponsoredAd
Creates a new SponsoredAd.
41 42 43 44 |
# File 'lib/gscraper/sponsored_ad.rb', line 41 def initialize(title,url) @title = title @url = url end |
Instance Attribute Details
#title ⇒ Object (readonly)
Title of the ad
27 28 29 |
# File 'lib/gscraper/sponsored_ad.rb', line 27 def title @title end |
#url ⇒ Object (readonly)
URL of the ad
30 31 32 |
# File 'lib/gscraper/sponsored_ad.rb', line 30 def url @url end |
Instance Method Details
#direct_link ⇒ String
The direct link of the ad.
52 53 54 |
# File 'lib/gscraper/sponsored_ad.rb', line 52 def direct_link @url.query_params['adurl'] || @url.query_params['q'] end |
#direct_url ⇒ URI::HTTP
The direct URI of the ad.
62 63 64 |
# File 'lib/gscraper/sponsored_ad.rb', line 62 def direct_url URI(URI.escape(direct_link)) end |
#to_s ⇒ String
The title of the ad.
72 73 74 |
# File 'lib/gscraper/sponsored_ad.rb', line 72 def to_s @title.to_s end |