class ProcBlock

Attributes

command[RW]

Public Class Methods

new( command, opts, stmts ) click to toggle source
# File lib/statsailr/block_builder/sts_block.rb, line 105
def initialize( command, opts, stmts )
  @command = command
  @opts = opts
  @stmts = stmts
end
new_from_gram_node( node ) click to toggle source
# File lib/statsailr/block_builder/sts_block.rb, line 111
def self.new_from_gram_node( node )
  proc_command = type_adjust( node.e1.e1, :string )

  proc_opt_hash = {}
  proc_opts = node.e2
  if(! proc_opts.nil?)
    proc_opts.each(){|nd|
      proc_opt_key = nd.e1
      proc_opt_val = type_adjust( nd.e2.e1 , nd.e2.type )
      proc_opt_hash[proc_opt_key] = proc_opt_val
    }
  else
    proc_opt_hash = {}
  end

  proc_stmts = []

  proc_stmts_ori = node.e3
  proc_stmts_ori.each(){|proc_stmt_ori|
      proc_stmt_inst = ""
      proc_stmt_arg = []
      proc_stmt_opt_hash = {}

      proc_stmt_inst = type_adjust( proc_stmt_ori.e1.e1, :string) # String
      proc_stmt_arg_ori = proc_stmt_ori.e2
      if ! proc_stmt_arg_ori.nil? then
        idx = 0
        while idx < proc_stmt_arg_ori.size() do
          elem = proc_stmt_arg_ori[idx]
          if( elem.type == :sign && elem.e1 == "/" )
            break
          else
            x = type_adjust( elem.e1, elem.type )
            proc_stmt_arg << x
            idx = idx + 1
          end
        end
        idx = idx + 1
        if idx < proc_stmt_arg_ori.size()

          proc_stmt_opt_hash = STSBlockParseProcOpts.include(BlockSupport).new(proc_stmt_arg_ori, idx).parse()
        else
          proc_stmt_opt_hash = {}
        end
      else  # When no arguments (even )
        prc_stmt_arg = []
      end

      proc_stmts.push( [proc_stmt_inst, proc_stmt_arg, proc_stmt_opt_hash ] )
  }

  return ProcBlock.new( proc_command , proc_opt_hash, proc_stmts)
end