Class: Badginator::Badge

Inherits:
Object
  • Object
show all
Defined in:
lib/badginator/badge.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.setters(*method_names) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/badginator/badge.rb', line 4

def self.setters(*method_names)
  method_names.each do |name|
    send :define_method, name do |*data|
      if data.length > 0
        instance_variable_set "@#{name}", data.first
      else
        instance_variable_get "@#{name}"
      end

    end
  end
end

Instance Method Details

#build_badge(&block) ⇒ Object



20
21
22
23
# File 'lib/badginator/badge.rb', line 20

def build_badge(&block)
  instance_eval &block
  @code = @code.to_sym if @code
end