Sha256: 6fa6fcbc2621798d1387701b8da450a3b1ac43d8adadf3c1254ccaa91d43c1b4

Contents?: true

Size: 1.58 KB

Versions: 8

Compression:

Stored size: 1.58 KB

Contents

require 'forwardable'

module Lucid
  class Runtime
    # This is what a programming language will consider to be a runtime.
    #
    # It's a thin class that directs the handul of 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,
        :features_paths,
        :step_match

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

      # Returns a Lucid::AST::Table for +text_or_table+, which can either
      # be a String:
      #
      #   table(%{
      #     | account | description | amount |
      #     | INT-100 | Taxi        | 114    |
      #     | CUC-101 | Peeler      | 22     |
      #   })
      #
      # or a 2D Array:
      #
      #   table([
      #     %w{ account description amount },
      #     %w{ INT-100 Taxi        114    },
      #     %w{ CUC-101 Peeler      22     }
      #   ])
      #
      def table(text_or_table, file=nil, line_offset=0)
        if Array === text_or_table
          AST::Table.new(text_or_table)
        else
          AST::Table.parse(text_or_table, file, line_offset)
        end
      end

      # Returns AST::DocString for +string_without_triple_quotes+.
      #
      def doc_string(string_without_triple_quotes, content_type='', line_offset=0)
        AST::DocString.new(string_without_triple_quotes,content_type)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
lucid-0.2.0 lib/lucid/runtime/facade.rb
lucid-0.1.1 lib/lucid/runtime/facade.rb
lucid-0.1.0 lib/lucid/runtime/facade.rb
lucid-0.0.9 lib/lucid/runtime/facade.rb
lucid-0.0.8 lib/lucid/runtime/facade.rb
lucid-0.0.7 lib/lucid/runtime/facade.rb
lucid-0.0.6 lib/lucid/runtime/facade.rb
lucid-0.0.5 lib/lucid/runtime/facade.rb