Class: Gamercard::Template
Direct Known Subclasses
Defined Under Namespace
Classes: OptionError
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#generated ⇒ Object
readonly
Returns the value of attribute generated.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#passed_settings ⇒ Object
readonly
Returns the value of attribute passed_settings.
-
#stats ⇒ Object
readonly
Returns the value of attribute stats.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Class Method Summary collapse
Instance Method Summary collapse
- #gradient_background(top_color = '#4a465a', bottom_color = 'black') ⇒ Object
-
#initialize(settings = {}) ⇒ Template
constructor
A new instance of Template.
-
#save(path = nil) ⇒ Object
template helpers inherited by all templates.
- #to_io ⇒ Object
Constructor Details
#initialize(settings = {}) ⇒ Template
Returns a new instance of Template.
10 11 12 13 14 |
# File 'lib/template.rb', line 10 def initialize(settings={}) @passed_settings = settings @generated = false process_settings(settings) if self.class.method_defined?(:process_settings) end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
8 9 10 |
# File 'lib/template.rb', line 8 def base @base end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
8 9 10 |
# File 'lib/template.rb', line 8 def filename @filename end |
#generated ⇒ Object (readonly)
Returns the value of attribute generated.
8 9 10 |
# File 'lib/template.rb', line 8 def generated @generated end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
8 9 10 |
# File 'lib/template.rb', line 8 def height @height end |
#passed_settings ⇒ Object (readonly)
Returns the value of attribute passed_settings.
7 8 9 |
# File 'lib/template.rb', line 7 def passed_settings @passed_settings end |
#stats ⇒ Object (readonly)
Returns the value of attribute stats.
8 9 10 |
# File 'lib/template.rb', line 8 def stats @stats end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
8 9 10 |
# File 'lib/template.rb', line 8 def username @username end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
8 9 10 |
# File 'lib/template.rb', line 8 def width @width end |
Class Method Details
.fonts_path ⇒ Object
16 17 18 |
# File 'lib/template.rb', line 16 def self.fonts_path File.(File.join(File.dirname(__FILE__), 'fonts')) end |
Instance Method Details
#gradient_background(top_color = '#4a465a', bottom_color = 'black') ⇒ Object
35 36 37 |
# File 'lib/template.rb', line 35 def gradient_background(top_color='#4a465a', bottom_color='black') Image.new(width, height, GradientFill.new(0, 0, width, 0, top_color, bottom_color)) end |
#save(path = nil) ⇒ Object
template helpers inherited by all templates
22 23 24 25 |
# File 'lib/template.rb', line 22 def save(path=nil) file_path = path.nil? ? (filename || 'image.png') : File.join(path, (filename || 'image.png')) base.write(file_path) end |
#to_io ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/template.rb', line 27 def to_io if @generated StringIO.new(base.to_blob{ self.format = 'PNG' }) else nil end end |