Class: Ergane::NamedBlock

Inherits:
Object
  • Object
show all
Defined in:
lib/ergane/switch_definition.rb

Class Method Summary collapse

Class Method Details

.new(*args, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/ergane/switch_definition.rb', line 3

def self.new(*args, &block)
  Class.new do
    args.each do |arg|
      attr_reader arg.to_sym
    end

    def initialize(label, args)
      @label = label.to_sym
      args.each do |arg, value|
        instance_variable_set("@#{args}", value)
      end
    end
  end
end