Class: GDstruct

Inherits:
Object
  • Object
show all
Defined in:
lib/gdstruct.rb,
lib/gdstruct/version.rb

Defined Under Namespace

Classes: Creator

Constant Summary collapse

VERSION =
'0.9.1'.freeze

Class Method Summary collapse

Class Method Details

.create(gds_definition, config = {}) ⇒ Hash, Array Also known as: c

create a Ruby Hash/Array structure out of a GDS definition string

Examples:

require 'gdstruct'

h = GDstruct.c( <<-EOS )
a value 1
b value 2
EOS

# => h = { a: 'value 1', b: 'value 2' }

Parameters:

  • gds_definition (String)

    GDS definition

  • config (Hash) (defaults to: {})

    a customizable set of options

Options Hash (config):

  • :allow_env (true/false) — default: false

    allow the @env directive to access environment variables, otherwise the @env directive returns nil

  • :context (Binding) — default: nil

    if a binding is set then the @r directive evaluates embedded ruby code, otherwise the @r directive returns nil

Returns:

  • (Hash, Array)

    hash/array structure



29
30
31
# File 'lib/gdstruct.rb', line 29

def create( gds_definition, config = {} )
  LDLgeneratedLanguage::Gds.parse( gds_definition, config )
end

.create_from_file(file_name, config = {}) ⇒ Hash, Array Also known as: c_from_file

create a Ruby Hash/Array structure out of a GDS definition file

Parameters:

  • file_name (String)

    file name

  • config (Hash) (defaults to: {})

    a customizable set of options

Options Hash (config):

  • :allow_env (true/false) — default: false

    allow the @env directive to access environment variables, otherwise the @env directive returns nil

  • :context (Binding) — default: nil

    if a binding is set then the @r directive evaluates embedded ruby code, otherwise the @r directive returns nil

Returns:

  • (Hash, Array)

    hash/array structure



41
42
43
# File 'lib/gdstruct.rb', line 41

def create_from_file( file_name, config = {} )
  LDLgeneratedLanguage::Gds.parse( File.read( file_name ), config )
end