Class: Avatari::Avatar
- Inherits:
-
Object
- Object
- Avatari::Avatar
- Defined in:
- lib/avatari/avatar.rb
Instance Attribute Summary collapse
-
#colors ⇒ Object
Returns the value of attribute colors.
-
#default_version ⇒ Object
Returns the value of attribute default_version.
-
#extension_whitelist ⇒ Object
Returns the value of attribute extension_whitelist.
-
#initials_method ⇒ Object
Returns the value of attribute initials_method.
-
#process ⇒ Object
Returns the value of attribute process.
-
#versions ⇒ Object
Returns the value of attribute versions.
Instance Method Summary collapse
-
#initialize(initials_method = nil, options = {}) ⇒ Avatar
constructor
A new instance of Avatar.
- #initials(object) ⇒ Object
Constructor Details
#initialize(initials_method = nil, options = {}) ⇒ Avatar
Returns a new instance of Avatar.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/avatari/avatar.rb', line 11 def initialize initials_method = nil, = {} defaults = { colors: ['#000000'], versions: { mini: [40,40], tiny: [50,50], small: [75,75], medium: [100,100], big: [350,350], raw: [800,800] }, default_version: nil, process: [800,800], extension_whitelist: ['jpg','jpeg','png'] } = defaults.merge! @initials_method = initials_method @colors = [:colors] @versions = [:versions] @default_version = [:default_version] @process = [:process] @extension_whitelist = [:extension_whitelist] end |
Instance Attribute Details
#colors ⇒ Object
Returns the value of attribute colors.
5 6 7 |
# File 'lib/avatari/avatar.rb', line 5 def colors @colors end |
#default_version ⇒ Object
Returns the value of attribute default_version.
7 8 9 |
# File 'lib/avatari/avatar.rb', line 7 def default_version @default_version end |
#extension_whitelist ⇒ Object
Returns the value of attribute extension_whitelist.
9 10 11 |
# File 'lib/avatari/avatar.rb', line 9 def extension_whitelist @extension_whitelist end |
#initials_method ⇒ Object
Returns the value of attribute initials_method.
4 5 6 |
# File 'lib/avatari/avatar.rb', line 4 def initials_method @initials_method end |
#process ⇒ Object
Returns the value of attribute process.
8 9 10 |
# File 'lib/avatari/avatar.rb', line 8 def process @process end |
#versions ⇒ Object
Returns the value of attribute versions.
6 7 8 |
# File 'lib/avatari/avatar.rb', line 6 def versions @versions end |
Instance Method Details
#initials(object) ⇒ Object
36 37 38 39 40 |
# File 'lib/avatari/avatar.rb', line 36 def initials object raw = object.send(self.initials_method) r = ''; raw.nil? ? nil : raw.split(' ').first(2).each { |n| r += n[0].upcase } return r end |