Sha256: c273979a75c475de063a0d23207737caa3581e92ee000a835a5fafa2cad4e2db

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

require 'forwardable'

module Lucid
  class ContextLoader
    # This is what a programming language will consider to be a runtime.
    #
    # It's a thin class that directs the specific methods needed by the
    # programming languages to the right place.
    class Facade
      extend Forwardable

      def initialize(orchestrator, interface)
        @orchestrator, @interface = orchestrator, interface
      end

      def_delegators :@interface,
        :embed,
        :ask,
        :puts,
        :specs_paths,
        :step_match

      def_delegators :@orchestrator,
        :invoke_steps,
        :invoke,
        :load_code_language

      # Returns a Lucid::AST::Table which can either be a String:
      #
      #   table(%{
      #     | study   | phase  |
      #     | Test-01 | I      |
      #     | Test-02 | II     |
      #   })
      #
      # or a 2D Array:
      #
      #   table([
      #     %w{ study phase },
      #     %w{ Test-01 I },
      #     %w{ Test-02 II }
      #   ])
      #
      def table(text_or_table, file=nil, line_offset=0)
        if Array === text_or_table
          Lucid::AST::Table.new(text_or_table)
        else
          Lucid::AST::Table.parse(text_or_table, file, line_offset)
        end
      end

      def doc_string(non_docstring, content_type='', line_offset=0)
        Lucid::AST::DocString.new(non_docstring, content_type)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lucid-0.5.1 lib/lucid/facade.rb
lucid-0.4.1 lib/lucid/facade.rb
lucid-0.4.0 lib/lucid/facade.rb