Class: Bgem::Config::MacroDir

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

Instance Method Summary collapse

Constructor Details

#initialize(type, dir) ⇒ MacroDir

Returns a new instance of MacroDir.



70
71
72
73
# File 'lib/bgem.rb', line 70

def initialize type, dir
  @type, @dir = type, dir
  @constant = Output::Exts.const_get @type.upcase
end

Instance Method Details

#define_macrosObject



75
76
77
78
79
80
81
82
83
84
85
# File 'lib/bgem.rb', line 75

def define_macros
  files = @dir.glob '*.rb'

  files.each do |file|
    n = file.basename.to_s.split('.').first
    constant = @constant; k = Class.new { include constant }
    to_s = "define_method :to_s do\n#{file.read}\nend"
    k.instance_eval to_s
    constant.const_set n.capitalize, k
  end
end