Class: Object

Inherits:
BasicObject
Defined in:
lib/sbn/helpers.rb

Overview

Thanks to Brian Schrer <ruby.brian at gmail.com> for the following two methods, from ruby-talk post #150456.

Class Method Summary collapse

Class Method Details

.bitwise_enums(*args) ⇒ Object



34
35
36
37
38
# File 'lib/sbn/helpers.rb', line 34

def self.bitwise_enums(*args)    
  args.flatten.each_with_index do |const, i|
    class_eval %(#{const} = #{2**i})
  end
end

.enums(*args) ⇒ Object

:nodoc:



28
29
30
31
32
# File 'lib/sbn/helpers.rb', line 28

def self.enums(*args)    
  args.flatten.each_with_index do |const, i|
    class_eval %(#{const} = #{i})
  end
end