Class: Module

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

Overview

module Inline

Instance Method Summary collapse

Instance Method Details

#inline(lang = :C, options = {}) {|builder| ... } ⇒ Object

Extends the Module class to have an inline method. The default language/builder used is C, but can be specified with the lang parameter.

Yields:

  • (builder)


822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
# File 'lib/inline.rb', line 822

def inline(lang = :C, options={})
  Inline.register self

  case options
  when TrueClass, FalseClass then
    warn "WAR\NING: 2nd argument to inline is now a hash, changing to {:testing=>#{options}}" unless options
    options = { :testing => options  }
  when Hash
    options[:testing] ||= false
  else
    raise ArgumentError, "BLAH"
  end

  builder_class = begin
                    Inline.const_get(lang)
                  rescue NameError
                    require "inline/#{lang}"
                    Inline.const_get(lang)
                  end

  builder = builder_class.new self

  yield builder

  unless options[:testing] then
    unless builder.load_cache then
      builder.build
      builder.load
    end
  end
end