Sha256: 8760b95a83f78b985e25db1f06fbd0bffc985fb8f3fd1f38aa4c2b252dec1648

Contents?: true

Size: 595 Bytes

Versions: 2

Compression:

Stored size: 595 Bytes

Contents

# frozen_string_literal: true

module FuncRunner
  class FunctionDefinition
    attr_reader :name, :desc, :param_types, :function_body

    def initialize(name)
      @name = name
      @param_types = {}
    end

    # Define expected parameter types
    def params(types)
      @param_types = types
    end

    def description(desc)
      @desc = desc
    end

    # Define the function body
    def body(&block)
      @function_body = block
    end

    # Convert to hash for storage
    def to_h
      {name: name, desc: desc, params: param_types, function: function_body}
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
funcrunner-0.1.1 lib/func_runner/function_definition.rb
funcrunner-0.1.0 lib/func_runner/function_definition.rb