Class: Basic
- Inherits:
-
Gamercard::Template
- Object
- Gamercard::Template
- Basic
- Defined in:
- lib/templates/basic.rb
Instance Attribute Summary
Attributes inherited from Gamercard::Template
#base, #filename, #generated, #height, #passed_settings, #stats, #username, #width
Instance Method Summary collapse
-
#generate(username, stats = {}) ⇒ Object
Returns an image.
-
#process_settings(passed_settings = {}) ⇒ Object
method getting called when a new instance is initiated it’s called directly from within initialize.
- #settings ⇒ Object
- #username_font ⇒ Object
- #username_label ⇒ Object
Methods inherited from Gamercard::Template
fonts_path, #gradient_background, #initialize, #save, #to_io
Constructor Details
This class inherits a constructor from Gamercard::Template
Instance Method Details
#generate(username, stats = {}) ⇒ Object
Returns an image
41 42 43 44 45 46 47 48 49 |
# File 'lib/templates/basic.rb', line 41 def generate(username, stats={}) @username = username @filename = "#{username}.png" @stats = stats @d = Draw.new @base = gradient_background # uses the template helper with default values username_label @generated = true end |
#process_settings(passed_settings = {}) ⇒ Object
method getting called when a new instance is initiated it’s called directly from within initialize
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/templates/basic.rb', line 9 def process_settings(passed_settings={}) # we could do something with the passed_settings but in this template # only the default settings are used @columns = @width = 600.0 @rows = @height = 100.0 @font_color = 'white' @font = 'Vera.ttf' @margin = 10.0 @avatar_width = (@rows - @margin) @avatar_x = (@columns - (@avatar_width + (@margin/2))) @avatar_y = ((@rows - @avatar_width)/2) end |
#settings ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/templates/basic.rb', line 22 def settings { :width => @columns, :height => @rows, :font_color => @font_color, :font => @font, :margin => @margin, :avatar_width => @avatar_width, :avatar_x => @avatar_x, :avatar_y => @avatar_y, :class_name => self.class.name } end |
#username_font ⇒ Object
36 37 38 |
# File 'lib/templates/basic.rb', line 36 def username_font File.join(::Gamercard::Template.fonts_path, @font) end |
#username_label ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/templates/basic.rb', line 51 def username_label @d.fill = @font_color @d.font = username_font @d.pointsize = 14.0 @d.stroke('transparent') @d.font_weight = NormalWeight @d.gravity = WestGravity @d = @d.annotate_scaled(@base, @columns, 1.0, @margin, @margin, "#{@username}", 1) end |