Class: Avatar::Source::StaticUrlSource
- Inherits:
-
Object
- Object
- Avatar::Source::StaticUrlSource
- Includes:
- AbstractSource
- Defined in:
- lib/avatar/source/static_url_source.rb
Overview
Source representing a constant URL. Good as a default or last-resort source.
Instance Attribute Summary collapse
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#avatar_url_for(person, options = {}) ⇒ Object
Returns nil if person is nil; the static url otherwise.
-
#initialize(url) ⇒ StaticUrlSource
constructor
Create a new source with static url
url
.
Constructor Details
#initialize(url) ⇒ StaticUrlSource
Create a new source with static url url
.
13 14 15 16 |
# File 'lib/avatar/source/static_url_source.rb', line 13 def initialize(url) raise ArgumentError.new("URL cannot be nil") if url.nil? @url = url.to_s end |
Instance Attribute Details
#url ⇒ Object
Returns the value of attribute url.
10 11 12 |
# File 'lib/avatar/source/static_url_source.rb', line 10 def url @url end |
Instance Method Details
#avatar_url_for(person, options = {}) ⇒ Object
Returns nil if person is nil; the static url otherwise.
19 20 21 |
# File 'lib/avatar/source/static_url_source.rb', line 19 def avatar_url_for(person, = {}) person.nil? ? nil : url end |