Class: Limelight::Templates::PlayerTemplater
- Defined in:
- lib/limelight/templates/player_templater.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#tokens ⇒ Object
readonly
Returns the value of attribute tokens.
Attributes inherited from Templater
#logger, #source_root, #target_root
Instance Method Summary collapse
-
#generate ⇒ Object
Generates the files.
-
#initialize(player_name) ⇒ PlayerTemplater
constructor
A new instance of PlayerTemplater.
Methods inherited from Templater
clarify, #directory, #file, source_dir
Constructor Details
#initialize(player_name) ⇒ PlayerTemplater
Returns a new instance of PlayerTemplater.
11 12 13 14 15 16 17 18 |
# File 'lib/limelight/templates/player_templater.rb', line 11 def initialize(player_name) super(".") @tokens = {} @tokens[:PLAYER_NAME] = player_name clean_name = player_name.gsub(/[\?\*!'\-.;:]/, "").gsub(" ", "_").downcase @filename = @tokens[:FILENAME] = clean_name @tokens[:CLASSNAME] = clean_name.camalized end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
9 10 11 |
# File 'lib/limelight/templates/player_templater.rb', line 9 def filename @filename end |
#tokens ⇒ Object (readonly)
Returns the value of attribute tokens.
9 10 11 |
# File 'lib/limelight/templates/player_templater.rb', line 9 def tokens @tokens end |
Instance Method Details
#generate ⇒ Object
Generates the files
22 23 24 25 26 27 28 |
# File 'lib/limelight/templates/player_templater.rb', line 22 def generate file(File.join(filename, "Rakefile"), "Rakefile.template", @tokens) file(File.join(filename, "Battleship.Rakefile"), "Battleship.Rakefile.template", @tokens) file(File.join(filename, "lib", filename, "#{filename}.rb"), "player.template", @tokens) file(File.join(filename, "spec", "spec_helper.rb"), "spec_helper.template", @tokens) file(File.join(filename, "spec", filename, "#{filename}_spec.rb"), "player_spec.template", @tokens) end |