Class: Ircbot::Client::Config::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/ircbot/client/config/generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Generator

Returns a new instance of Generator.



9
10
11
12
13
14
# File 'lib/ircbot/client/config/generator.rb', line 9

def initialize(options = {})
  @nick = options[:nick]
  @code = options[:code] || read_template

  @nick = current_user + "_bot" if @nick.to_s.empty?
end

Instance Attribute Details

#nickObject (readonly)

Returns the value of attribute nick.



7
8
9
# File 'lib/ircbot/client/config/generator.rb', line 7

def nick
  @nick
end

Instance Method Details

#executeObject



16
17
18
19
20
# File 'lib/ircbot/client/config/generator.rb', line 16

def execute
  require 'erb'
  erb = ERB.new(@code)
  erb.result(binding)
end