Class: UtmGenerator
- Inherits:
-
Object
- Object
- UtmGenerator
- Includes:
- ActiveModel::Model
- Defined in:
- lib/utm_generator.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
Returns the value of attribute url.
-
#utm_campaign ⇒ Object
Returns the value of attribute utm_campaign.
-
#utm_content ⇒ Object
Returns the value of attribute utm_content.
-
#utm_medium ⇒ Object
Returns the value of attribute utm_medium.
-
#utm_source ⇒ Object
Returns the value of attribute utm_source.
-
#utm_term ⇒ Object
Returns the value of attribute utm_term.
Instance Method Summary collapse
Instance Attribute Details
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/utm_generator.rb', line 3 def url @url end |
#utm_campaign ⇒ Object
Returns the value of attribute utm_campaign.
3 4 5 |
# File 'lib/utm_generator.rb', line 3 def utm_campaign @utm_campaign end |
#utm_content ⇒ Object
Returns the value of attribute utm_content.
3 4 5 |
# File 'lib/utm_generator.rb', line 3 def utm_content @utm_content end |
#utm_medium ⇒ Object
Returns the value of attribute utm_medium.
3 4 5 |
# File 'lib/utm_generator.rb', line 3 def utm_medium @utm_medium end |
#utm_source ⇒ Object
Returns the value of attribute utm_source.
3 4 5 |
# File 'lib/utm_generator.rb', line 3 def utm_source @utm_source end |
#utm_term ⇒ Object
Returns the value of attribute utm_term.
3 4 5 |
# File 'lib/utm_generator.rb', line 3 def utm_term @utm_term end |
Instance Method Details
#generate_url ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/utm_generator.rb', line 8 def generate_url if valid? uri = URI(url) params = [] params << [:utm_source, utm_source] params << [:utm_medium, utm_medium] unless utm_medium.blank? params << [:utm_campaign, utm_campaign] unless utm_campaign.blank? params << [:utm_term, utm_term] unless utm_term.blank? params << [:utm_content, utm_content] unless utm_content.blank? uri.query = URI.encode_www_form(params) uri.to_s end end |