Class: Module

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

Overview

module Inline

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#optionsObject (readonly)

options is a hash that allows you to pass extra data to your builder. The only key that is guaranteed to exist is :testing.



794
795
796
# File 'lib/inline.rb', line 794

def options
  @options
end

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)


801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
# File 'lib/inline.rb', line 801

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

  @options = options
  builder = builder_class.new self

  yield builder

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