Class: LazyFuncGeneratorSetting

Inherits:
Object
  • Object
show all
Includes:
LazyFuncGeneratorSettingUtility
Defined in:
lib/statsailr/block_to_r/sts_lazy_func_gen.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from LazyFuncGeneratorSettingUtility

#is_param_name?, #is_r_obj?, #is_result_name?, #is_result_name_array?, #one_from, #param, #previous_inst_name, #previous_or, #r_obj, #read_as_formula, #read_as_intvec, #read_as_numvec, #read_as_one_str, #read_as_realvec, #read_as_strvec, #read_as_symbol, #read_named_args_as_named_strvec, #read_symbols_as_strvec, #read_symbols_or_functions_as_strvec, #result

Constructor Details

#initializeLazyFuncGeneratorSetting



232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/statsailr/block_to_r/sts_lazy_func_gen.rb', line 232

def initialize
  @libname = nil
  @envname = nil
  @func_name = nil

  @main_arg_and_how_to_treat = nil
  @runtime_args = nil

  @store_result = true
  @print_opt = nil
  @plot_opt = nil
end

Instance Attribute Details

#envnameObject

Returns the value of attribute envname.



231
232
233
# File 'lib/statsailr/block_to_r/sts_lazy_func_gen.rb', line 231

def envname
  @envname
end

#func_nameObject

Returns the value of attribute func_name.



231
232
233
# File 'lib/statsailr/block_to_r/sts_lazy_func_gen.rb', line 231

def func_name
  @func_name
end

#libnameObject

Returns the value of attribute libname.



231
232
233
# File 'lib/statsailr/block_to_r/sts_lazy_func_gen.rb', line 231

def libname
  @libname
end

#main_arg_and_how_to_treatObject

Returns the value of attribute main_arg_and_how_to_treat.



231
232
233
# File 'lib/statsailr/block_to_r/sts_lazy_func_gen.rb', line 231

def main_arg_and_how_to_treat
  @main_arg_and_how_to_treat
end

#plot_optObject

Returns the value of attribute plot_opt.



231
232
233
# File 'lib/statsailr/block_to_r/sts_lazy_func_gen.rb', line 231

def plot_opt
  @plot_opt
end

Returns the value of attribute print_opt.



231
232
233
# File 'lib/statsailr/block_to_r/sts_lazy_func_gen.rb', line 231

def print_opt
  @print_opt
end

#runtime_argsObject

Returns the value of attribute runtime_args.



231
232
233
# File 'lib/statsailr/block_to_r/sts_lazy_func_gen.rb', line 231

def runtime_args
  @runtime_args
end

#store_resultObject

Returns the value of attribute store_result.



231
232
233
# File 'lib/statsailr/block_to_r/sts_lazy_func_gen.rb', line 231

def store_result
  @store_result
end

Instance Method Details

#create_func_arg_hash(main_arg, opt_args) ⇒ Object



245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
# File 'lib/statsailr/block_to_r/sts_lazy_func_gen.rb', line 245

def create_func_arg_hash( main_arg, opt_args )
  if ! @main_arg_and_how_to_treat.nil?
    main_arg_name, how_to_treat, allow_nil = @main_arg_and_how_to_treat
  else
    main_arg_name, how_to_treat, allow_nil = [nil, nil, nil]
  end
  runtime_args = @runtime_args

  if( ! main_arg_name.nil? )
    if( ! main_arg.empty? )
      if( how_to_treat.to_s =~ /^read/ )
        r_main_arg_hash = {main_arg_name => self.send( how_to_treat, main_arg)  }
      else
        raise "String element that specifies how_to_treat should start from 'read_'"
      end
    elsif allow_nil.to_s == "allow_nil"
      r_main_arg_hash = {}
    else
      raise "main_arg needs needs to be specified or setting.main_arg_and_how_to_treat needs to allow nil"
    end
  else
    r_main_arg_hash = {}
  end

  if( ! opt_args.nil? )
    r_opt_arg_hash = convert_args_to_r_args( opt_args )
  else
    r_opt_arg_hash = {}
  end

  if( !runtime_args.nil?)
    raise "rumtime_args needs to be Hash" if ! runtime_args.is_a?( Hash )
  else
    runtime_args = {}
  end

  r_args = {}
  r_args.merge!( runtime_args )
  r_args.merge!( r_opt_arg_hash )
  r_args.merge!( r_main_arg_hash )
  # The latter hashes have higher priority

  return r_args
end