Class: JustShare::SocialLinker

Inherits:
Object
  • Object
show all
Defined in:
lib/just_share/social_linker.rb

Overview

ParentClass which have the attrs to create the links

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ SocialLinker

It constructor must be reused by it children



19
20
21
22
23
24
25
26
27
# File 'lib/just_share/social_linker.rb', line 19

def initialize(params={})
  # SetUp the attrs
  self.via=params[:via] || self.via=JustShare.via
  self.aux_link=params[:link] || self.aux_link=JustShare.link
  self.title=params[:title] || self.message=JustShare.title
  self.message=params[:message] || self.message=JustShare.message
  self.hash_tags=params[:hash_tags] || self.hash_tags=JustShare.hash_tags
  self.image_url=params[:image_url] || self.hash_tags=JustShare.image_url
end

Instance Attribute Details

The redirect link on the post



8
9
10
# File 'lib/just_share/social_linker.rb', line 8

def aux_link
  @aux_link
end

#domainObject

Attrs filled on children



14
15
16
# File 'lib/just_share/social_linker.rb', line 14

def domain
  @domain
end

#hash_tagsObject

Array of HashTags, like nature, sunset, HereWeGo…



10
11
12
# File 'lib/just_share/social_linker.rb', line 10

def hash_tags
  @hash_tags
end

#image_urlObject

URL to the image



11
12
13
# File 'lib/just_share/social_linker.rb', line 11

def image_url
  @image_url
end

#messageObject

Base Message (like from the Ad.social_message)



7
8
9
# File 'lib/just_share/social_linker.rb', line 7

def message
  @message
end

#paramsObject

ex: facebook.com twitter.com …



16
17
18
# File 'lib/just_share/social_linker.rb', line 16

def params
  @params
end

#pathObject

ex: facebook.com twitter.com …



15
16
17
# File 'lib/just_share/social_linker.rb', line 15

def path
  @path
end

#titleObject

Attrs accessor for it classes



6
7
8
# File 'lib/just_share/social_linker.rb', line 6

def title
  @title
end

#viaObject

The app which post like: PageRenter



9
10
11
# File 'lib/just_share/social_linker.rb', line 9

def via
  @via
end

Instance Method Details

#get_post_linkObject

FacadeMethod



30
31
32
33
34
35
# File 'lib/just_share/social_linker.rb', line 30

def get_post_link
  # SetUp attrs
  setup_attrs
  # Create & return it URL created
  "#{self.domain}/#{self.path}?#{params}"
end

Overwriting the link getter to return it encoded as HTTP uses



38
39
40
# File 'lib/just_share/social_linker.rb', line 38

def link
  CGI::escape(self.aux_link) unless self.aux_link.nil?
end

#setup_attrsObject

Method to be implemented on it children!



43
44
# File 'lib/just_share/social_linker.rb', line 43

def setup_attrs
end