Class: ProfileLinkGenerator
- Inherits:
-
Object
- Object
- ProfileLinkGenerator
- Defined in:
- lib/link_to_profile/profile_link_generator.rb
Defined Under Namespace
Classes: ArgumentError
Instance Attribute Summary collapse
-
#network ⇒ Object
readonly
Returns the value of attribute network.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ ProfileLinkGenerator
constructor
A new instance of ProfileLinkGenerator.
- #link ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ ProfileLinkGenerator
Returns a new instance of ProfileLinkGenerator.
6 7 8 9 10 11 12 |
# File 'lib/link_to_profile/profile_link_generator.rb', line 6 def initialize( = {}) @options = @username = [:username] @network = [:network] raise ArgumentError if @username.nil? or @network.nil? end |
Instance Attribute Details
#network ⇒ Object (readonly)
Returns the value of attribute network.
4 5 6 |
# File 'lib/link_to_profile/profile_link_generator.rb', line 4 def network @network end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/link_to_profile/profile_link_generator.rb', line 4 def @options end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
4 5 6 |
# File 'lib/link_to_profile/profile_link_generator.rb', line 4 def username @username end |
Instance Method Details
#link ⇒ Object
18 19 20 |
# File 'lib/link_to_profile/profile_link_generator.rb', line 18 def link "<a href='#{url}'>#{network}</a>" end |
#url ⇒ Object
14 15 16 |
# File 'lib/link_to_profile/profile_link_generator.rb', line 14 def url templates[network.to_s].sub(/{{username}}/, username) end |