Class: Sigen
- Inherits:
-
Object
- Object
- Sigen
- Defined in:
- lib/sigen.rb
Class Method Summary collapse
-
.perform(username, stats, template, output_path = nil) ⇒ Object
Creates a gamer card signature and saves it in ‘save_dir` which points to ’/tmp/sigen/signatures’ by default.
-
.save_dir ⇒ Object
location when the signatures will be saved.
- .save_dir=(path) ⇒ Object
Class Method Details
.perform(username, stats, template, output_path = nil) ⇒ Object
Creates a gamer card signature and saves it in ‘save_dir` which points to ’/tmp/sigen/signatures’ by default.
Parameters
- username<~to_s>
-
Username of the player, used to fetch avatar and save the signature.
- stats<Hash>
-
The stats used in the template. The template will look for the stats using hash keys.
- template<Hash>
-
Template info used to generate the signature. Keys are expected to be strings and not symbols.
Only the name key is required. Keys are expected to be strings and not symbols.
- output_path<String>
-
Optional path ti save the output signature.
If not passed, the `save_dir` value will be used.
Returns
- Boolean
-
reports the success of the signature creation.
Examples
Sigen.perform(‘mattetti’,
{'rank' => 123, 'team' => 'Cubs', 'last_win' => '2010-04-27'},
{:name => 'mlb10', :style => 'Cubs'})
Sigen.perform(‘mattetti’,
{'rank' => 123, 'team' => 'Cubs', 'last_win' => '2010-04-27'},
{:name => 'mlb10', :style => 'Cubs'},
'/tmp/mlb10')
47 48 49 50 51 52 |
# File 'lib/sigen.rb', line 47 def self.perform(username, stats, template, output_path=nil) card = GamerCard.new(template) card.generate(username, stats) # path = output_path.nil? ? save_dir : output_path # card.save(path) end |
.save_dir ⇒ Object
location when the signatures will be saved
9 10 11 12 13 14 15 |
# File 'lib/sigen.rb', line 9 def self.save_dir if @save_dir @save_dir else self.save_dir = @default_save_dir end end |
.save_dir=(path) ⇒ Object
17 18 19 20 21 |
# File 'lib/sigen.rb', line 17 def self.save_dir=(path) @save_dir = path FileUtils.mkdir_p(@save_dir) unless File.exist?(@save_dir) @save_dir end |