Top Level Namespace

Defined Under Namespace

Classes: Kibuvits_krl171bt4_GUID_generator, Kibuvits_krl171bt4_IDstamp_registry_t1, Kibuvits_krl171bt4_ImageMagick, Kibuvits_krl171bt4_ProgFTE, Kibuvits_krl171bt4_ProgFTE_v0, Kibuvits_krl171bt4_ProgFTE_v1, Kibuvits_krl171bt4_REDUCE, Kibuvits_krl171bt4_apparch_specific, Kibuvits_krl171bt4_argv_parser, Kibuvits_krl171bt4_arraycursor_t1, Kibuvits_krl171bt4_cg, Kibuvits_krl171bt4_cg_html_t1, Kibuvits_krl171bt4_cg_php_t1, Kibuvits_krl171bt4_cleartext_length_normalization, Kibuvits_krl171bt4_comments_detector, Kibuvits_krl171bt4_configfileparser_t1, Kibuvits_krl171bt4_coords, Kibuvits_krl171bt4_cryptcodec_txor_t1, Kibuvits_krl171bt4_data_transfer, Kibuvits_krl171bt4_dependencymetrics_t1, Kibuvits_krl171bt4_eval, Kibuvits_krl171bt4_eval_bridge, Kibuvits_krl171bt4_eval_bridge_PHP5, Kibuvits_krl171bt4_eval_bridge_Ruby, Kibuvits_krl171bt4_file_intelligence, Kibuvits_krl171bt4_finite_sets, Kibuvits_krl171bt4_formula, Kibuvits_krl171bt4_fs, Kibuvits_krl171bt4_graph_oper_t1, Kibuvits_krl171bt4_graph_vertex, Kibuvits_krl171bt4_gstatement, Kibuvits_krl171bt4_hash_plaice_t1, Kibuvits_krl171bt4_histogram_t1, Kibuvits_krl171bt4_histogram_t1_tests, Kibuvits_krl171bt4_htoper_t1, Kibuvits_krl171bt4_i18n_msgs_t1, Kibuvits_krl171bt4_io, Kibuvits_krl171bt4_ix, Kibuvits_krl171bt4_keyboard, Kibuvits_krl171bt4_msgc, Kibuvits_krl171bt4_msgc_stack, Kibuvits_krl171bt4_numerics_set_0, Kibuvits_krl171bt4_os_codelets, Kibuvits_krl171bt4_rake, Kibuvits_krl171bt4_refl, Kibuvits_krl171bt4_rng, Kibuvits_krl171bt4_security_core, Kibuvits_krl171bt4_shell, Kibuvits_krl171bt4_spider_t1, Kibuvits_krl171bt4_str, Kibuvits_krl171bt4_wholenumberID_generator

Constant Summary collapse

Fixnum =
Integer
Bignum =
Integer
KIBUVITS_krl171bt4_HOME =
ob_pth.to_s.freeze
KIBUVITS_krl171bt4_RUBY_LIBRARY_IS_AVAILABLE =

if

false
KIBUVITS_krl171bt4_s_PROCESS_ID =

The Operating system process ID-s tend to cycle. If the code that uses the KIBUVITS_krl171bt4_s_PROCESS_ID does not erase temporary files, which might actually be quite challenging, given that it’s not that easy to elegantly automatically determine, which of the sub-processes is the last one, then there might be collisions with the use of the temporary files, global hash entries, etc., unless the process ID-s are something like the Globally Unique Identifiers.

"pid_"+$$.to_s+"_"+
Kibuvits_krl171bt4_GUID_generator.generate_GUID
KIBUVITS_krl171bt4_s_VERSION =
"kibuvits_krl171bt4_"+KIBUVITS_krl171bt4_s_NUMERICAL_VERSION.to_s
KIBUVITS_krl171bt4_s_CMD_RUBY =
"cd "<<kibuvits_krl171bt4_tmpvar_s_rbpath<<" ; ruby -Ku "
KIBUVITS_krl171bt4_SHELL_RB_INCLUDED =
true
KIBUVITS_krl171bt4_HTOPER_RB_INCLUDED =
true
KIBUVITS_krl171bt4_I18N_MSGS_T1_RB_INCLUDED =
true
KIBUVITS_krl171bt4_DEPENDENCYMETRICS_T1_RB_INCLUDED =
true

Instance Method Summary collapse

Instance Method Details

#b_kibuvits_krl171bt4_ht_has_keys(x_key_candidate_or_ar_of_key_candidates, ht) ⇒ Object

Returns false if any of the x_key_candidate_or_ar_of_key_candidates elements is missing from the ht.keys



1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 1015

def b_kibuvits_krl171bt4_ht_has_keys(x_key_candidate_or_ar_of_key_candidates,ht)
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, Hash,ht
      kibuvits_krl171bt4_typecheck bn, [Array,String],x_key_candidate_or_ar_of_key_candidates
   end # if
   b_out=true
   if x_key_candidate_or_ar_of_key_candidates.class==Array
      x_key_candidate_or_ar_of_key_candidates.each do |x_key_candidate|
         if !ht.has_key? x_key_candidate
            b_out=false
            break
         end # if
      end # loop
   else
      b_out=ht.has_key? x_key_candidate_or_ar_of_key_candidates
   end # if
   return b_out
end

#kibuvits_krl171bt4_ar_i_2_file_t1(ar_i, s_file_path) ⇒ Object




6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 6773

def kibuvits_krl171bt4_ar_i_2_file_t1(ar_i,s_file_path)
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, Array, ar_i
      kibuvits_krl171bt4_typecheck bn, String, s_file_path
   end # if
   # Credits for the Array.pack solution go to:
   # http://stackoverflow.com/questions/941856/write-binary-file-in-ruby
   x_binary_string=ar_i.pack("C*") # 8 bit unsigned integer
   $kibuvits_krl171bt4_lc_mx_streamaccess.synchronize do
      begin
         File.open(s_file_path,"wb") do |file|
            file.write(x_binary_string)
         end # Open-file region.
      rescue Exception =>err
         raise(Exception.new("\n"+err.to_s+"\n\ns_file_path=="+
         s_file_path+
         "\n GUID='f8269d51-b2ed-47f8-b27f-c13290a118e7'\n\n"))
      end #
   end # synchronize
end

#kibuvits_krl171bt4_ar_i_dearmour_t1(s_armoured) ⇒ Object

kibuvits_krl171bt4_s_armour_t1



6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 6881

def kibuvits_krl171bt4_ar_i_dearmour_t1(s_armoured)
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, String, s_armoured
   end # if
   ar_out=Array.new
   ar_unicode=s_armoured.codepoints
   i_len=ar_unicode.size
   return ar_out if i_len==0
   i_zero="A000".to_i(16)
   i_x=nil
   if KIBUVITS_krl171bt4_b_DEBUG
      i_len.times do |ix|
         i_x=ar_unicode[ix]-i_zero
         if i_x<0
            kibuvits_krl171bt4_throw("i_x == "+i_x.to_s+" < 0 "+
            "\n GUID='5f3b20ed-5cda-49ee-b32f-c13290a118e7'\n\n")
         end # if
         if 255<i_x
            kibuvits_krl171bt4_throw(" 255 < i_x == "+i_x.to_s+
            "\n GUID='22f8a912-c70b-4a5b-830f-c13290a118e7'\n\n")
         end # if
         ar_out<<i_x
      end # loop
   else
      i_len.times do |ix|
         i_x=ar_unicode[ix]-i_zero
         ar_out<<i_x
      end # loop
   end # if
   return ar_out
end

#kibuvits_krl171bt4_assert_ar_elements_typecheck_if_is_array(a_binding, expected_class_or_an_array_of_expected_classes, ob, s_optional_error_message_suffix = nil) ⇒ Object

If the ob_or_ar is not of type Array, then it does not apply any tests and exits without throwing any exceptions.



2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 2042

def kibuvits_krl171bt4_assert_ar_elements_typecheck_if_is_array(a_binding,
   expected_class_or_an_array_of_expected_classes,
   ob,s_optional_error_message_suffix=nil)
   #----------
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, Binding, a_binding
      kibuvits_krl171bt4_typecheck bn, [Class,Array], expected_class_or_an_array_of_expected_classes
      kibuvits_krl171bt4_typecheck bn, [NilClass,String], s_optional_error_message_suffix
   end # if
   #----------
   ar_exp_classes=nil
   if expected_class_or_an_array_of_expected_classes.class==Array
      ar_exp_classes=expected_class_or_an_array_of_expected_classes
   else
      ar_exp_classes=[expected_class_or_an_array_of_expected_classes]
   end # if
   if KIBUVITS_krl171bt4_b_DEBUG
      if ar_exp_classes.size==0
         msg="ar_exp_classes.size==0\n"+
         "GUID='bf1d8648-49ff-45c8-a4d3-c13290a118e7'"
         kibuvits_krl171bt4_throw(msg)
      end # if
      bn_1=nil
      ar_exp_classes.each do |x_class_candidate|
         bn_1=binding()
         kibuvits_krl171bt4_typecheck bn_1, Class, x_class_candidate
      end # loop
   end # if
   #----------
   return if ob.class!=Array
   ar_ob_elems=ob
   #----------
   cl=nil
   ar_ob_elems.each do |x_elem|
      cl=x_elem.class
      kibuvits_krl171bt4_assert_is_among_values(a_binding,ar_exp_classes,
      cl,s_optional_error_message_suffix)
   end # loop
end

#kibuvits_krl171bt4_assert_array_min_length(a_binding, ar_in, i_min_length, s_optional_error_message_suffix = nil) ⇒ Object




1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 1278

def kibuvits_krl171bt4_assert_array_min_length(a_binding,ar_in,i_min_length,
   s_optional_error_message_suffix=nil)
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, Binding, a_binding
      kibuvits_krl171bt4_typecheck bn, Array, ar_in
      kibuvits_krl171bt4_typecheck bn, [Integer,Fixnum,Bignum], i_min_length
      kibuvits_krl171bt4_typecheck bn, [NilClass,String],s_optional_error_message_suffix
      if i_min_length<0
         kibuvits_krl171bt4_throw("i_min_length == "+i_min_length.to_s+" < 0");
      end # if
   end # if
   i_len=ar_in.size
   if i_len<i_min_length
      s_varname=kibuvits_krl171bt4_s_varvalue2varname(a_binding,ar_in)
      s_varname="<an array>" if s_varname.length==0
      kibuvits_krl171bt4_throw(s_varname+".size=="+i_len.to_s+", but the "+
      "minimum allowed array length is "+i_min_length.to_s+".",a_binding)
   end # if
end

#kibuvits_krl171bt4_assert_arrayix(a_binding, ar, i_array_index_candidate_or_array_of_array_index_candidates, s_optional_error_message_suffix = nil) ⇒ Object




1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 1345

def kibuvits_krl171bt4_assert_arrayix(a_binding,ar,
   i_array_index_candidate_or_array_of_array_index_candidates,
   s_optional_error_message_suffix=nil)
   x_candidates=i_array_index_candidate_or_array_of_array_index_candidates
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, Binding,a_binding
      kibuvits_krl171bt4_typecheck bn, Array,ar
      kibuvits_krl171bt4_typecheck bn, [Integer,Bignum,Fixnum,Array],i_array_index_candidate_or_array_of_array_index_candidates
      kibuvits_krl171bt4_typecheck bn, [NilClass,String],s_optional_error_message_suffix
      if x_candidates.class==Array
         if x_candidates.size==0
            kibuvits_krl171bt4_throw("The array of candidate indices is empty.")
         end # if
         x_candidates.each do |x|
            bn=binding()
            kibuvits_krl171bt4_typecheck bn,[Integer,Fixnum,Bignum],x
         end # loop
      end # if
   end # if
   ar_candidates=x_candidates
   if x_candidates.class==Integer
      ar_candidates=[x_candidates]
   else
      if x_candidates.class==Bignum
         ar_candidates=[x_candidates]
      else
         if x_candidates.class==Fixnum
            ar_candidates=[x_candidates]
         end # if
      end # if
   end # if
   i_cand_sindex_max=ar_candidates.size # array separator index, min==0
   i_number_of_candidates=i_cand_sindex_max # ==(i_cand_sindex_max-0)
   if i_number_of_candidates==0
      kibuvits_krl171bt4_throw("The array of candidate indices is empty.")
   end # if
   i_max_valid_ix=ar.size-1
   i_candidate=nil
   #------
   func_suffix=lambda do |s_or_nil_suffix|
      x_out=nil
      if s_or_nil_suffix!=nil
         x_out=$kibuvits_krl171bt4_lc_linebreak+s_or_nil_suffix.to_s
      else
         x_out=$kibuvits_krl171bt4_lc_emptystring
      end # if
      return x_out
   end # func_suffix
   #------
   i_number_of_candidates.times do |i|
      i_candidate=ar_candidates[i]
      if i_candidate<0
         s_suffix=func_suffix.call(s_optional_error_message_suffix)
         if i_number_of_candidates==1
            kibuvits_krl171bt4_throw("<array index candidate>"+
            " == "+i_candidate.to_s+" < 0 "+s_suffix,a_binding)
         else
            kibuvits_krl171bt4_throw("Array index candidate #"+i.to_s+
            " == "+i_candidate.to_s+" < 0 "+s_suffix,a_binding)
         end # if
      end # if
      if i_max_valid_ix<i_candidate
         s_suffix=func_suffix.call(s_optional_error_message_suffix)
         kibuvits_krl171bt4_throw("Maximum valid index is "+
         i_max_valid_ix.to_s+" < "+i_candidate.to_s+
         " == <index candidate>"+s_suffix,a_binding)
      end # if
   end # loop
end

#kibuvits_krl171bt4_assert_arrayixs(a_binding, ar, i_array_sindex_candidate_or_array_of_array_sindex_candidates, s_optional_error_message_suffix = nil) ⇒ Object



1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 1418

def kibuvits_krl171bt4_assert_arrayixs(a_binding,ar,
   i_array_sindex_candidate_or_array_of_array_sindex_candidates,
   s_optional_error_message_suffix=nil)
   x_candidates=i_array_sindex_candidate_or_array_of_array_sindex_candidates
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, Binding,a_binding
      kibuvits_krl171bt4_typecheck bn, Array,ar
      kibuvits_krl171bt4_typecheck bn, [Integer,Fixnum,Bignum,Array],i_array_sindex_candidate_or_array_of_array_sindex_candidates
      kibuvits_krl171bt4_typecheck bn, [NilClass,String],s_optional_error_message_suffix
      if x_candidates.class==Array
         if x_candidates.size==0
            kibuvits_krl171bt4_throw("The array of candidate sindices is empty.")
         end # if
         x_candidates.each do |x|
            bn=binding()
            kibuvits_krl171bt4_typecheck bn,[Integer,Fixnum,Bignum],x
         end # loop
      end # if
   end # if
   ar_candidates=x_candidates
   if x_candidates.class==Integer
      ar_candidates=[x_candidates]
   else
      if x_candidates.class==Bignum
         ar_candidates=[x_candidates]
      else
         if x_candidates.class==Fixnum
            ar_candidates=[x_candidates]
         end # if
      end # if
   end # if
   i_cand_sindex_max=ar_candidates.size # array separator index, min==0
   i_number_of_candidates=i_cand_sindex_max # ==(i_cand_sindex_max-0)
   if i_number_of_candidates==0
      kibuvits_krl171bt4_throw("The array of candidate sindices is empty.")
   end # if
   i_max_valid_ixs=ar.size
   i_candidate=nil
   #------
   func_suffix=lambda do |s_or_nil_suffix|
      x_out=nil
      if s_or_nil_suffix!=nil
         x_out=$kibuvits_krl171bt4_lc_linebreak+s_or_nil_suffix.to_s
      else
         x_out=$kibuvits_krl171bt4_lc_emptystring
      end # if
      return x_out
   end # func_suffix
   #------
   i_number_of_candidates.times do |i|
      i_candidate=ar_candidates[i]
      if i_candidate<0
         s_suffix=func_suffix.call(s_optional_error_message_suffix)
         if i_number_of_candidates==1
            kibuvits_krl171bt4_throw("<array sindex candidate>"+
            " == "+i_candidate.to_s+" < 0 "+s_suffix,a_binding)
         else
            kibuvits_krl171bt4_throw("Array sindex candidate #"+i.to_s+
            " == "+i_candidate.to_s+" < 0 "+s_suffix,a_binding)
         end # if
      end # if
      if i_max_valid_ixs<i_candidate
         s_suffix=func_suffix.call(s_optional_error_message_suffix)
         kibuvits_krl171bt4_throw("Maximum valid sindex is "+
         i_max_valid_ixs.to_s+" < "+i_candidate.to_s+
         " == <sindex candidate>"+s_suffix,a_binding)
      end # if
   end # loop
end

#kibuvits_krl171bt4_assert_class_name_prefix(a_binding, ob, x_class_name_prefix_as_string_or_class, s_optional_error_message_suffix = nil) ⇒ Object


If the width of a class name prefix can match that of the class name, then the assertion is considered met and no exceptions are thrown.



1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 1536

def kibuvits_krl171bt4_assert_class_name_prefix(a_binding,ob,
   x_class_name_prefix_as_string_or_class,
   s_optional_error_message_suffix=nil)
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, Binding,a_binding
      kibuvits_krl171bt4_typecheck bn, [String,Class],x_class_name_prefix_as_string_or_class
      kibuvits_krl171bt4_typecheck bn, [NilClass,String],s_optional_error_message_suffix
   end # if
   s_prefix=nil
   if x_class_name_prefix_as_string_or_class.class==Class
      s_prefix=x_class_name_prefix_as_string_or_class.to_s
   else
      s_prefix=x_class_name_prefix_as_string_or_class
      kibuvits_krl171bt4_assert_string_min_length(a_binding,s_prefix,1)
   end # if
   s_cl=ob.class.to_s
   rgx=Regexp.new($kibuvits_krl171bt4_lc_powersign+s_prefix+$kibuvits_krl171bt4_lc_dotstar)
   md=rgx.match(s_cl)
   if md==nil
      s_varname=kibuvits_krl171bt4_s_varvalue2varname(a_binding,ob)
      s_varname="<an object>" if s_varname.length==0
      msg=s_varname+".class.to_s==\""+s_cl+"\", but the "+
      "requested class name prefix is \""+s_prefix+"\". "
      if s_optional_error_message_suffix.class==String
         msg=msg+s_optional_error_message_suffix
      end # if
      kibuvits_krl171bt4_throw(msg,a_binding)
   end # if
end

#kibuvits_krl171bt4_assert_does_not_contain_common_special_characters_t1(a_binding, s_in, s_optional_error_message_suffix = nil) ⇒ Object

A similar function:

kibuvits_krl171bt4_assert_ok_to_be_a_varname_t1(...)


2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 2143

def kibuvits_krl171bt4_assert_does_not_contain_common_special_characters_t1(a_binding,s_in,
   s_optional_error_message_suffix=nil)
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, Binding, a_binding
      kibuvits_krl171bt4_typecheck bn, String, s_in
      kibuvits_krl171bt4_typecheck bn, [NilClass,String],s_optional_error_message_suffix
   end # if
   if kibuvits_krl171bt4_b_contains_common_special_characters_t1(s_in)
      s_varname=kibuvits_krl171bt4_s_varvalue2varname(a_binding,s_in)
      kibuvits_krl171bt4_throw("\n"+s_varname+"==\""+s_in.to_s+
      "\"\ncontains at least one character that "+
      "is commonly used as a special character. \n",a_binding)
   end # if
end

#kibuvits_krl171bt4_assert_ht_container_version(a_binding, ht_container, s_expected_version, s_optional_error_message_suffix = nil) ⇒ Object




1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 1491

def kibuvits_krl171bt4_assert_ht_container_version(a_binding,ht_container,s_expected_version,
   s_optional_error_message_suffix=nil)
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, Binding,a_binding
      kibuvits_krl171bt4_typecheck bn, Hash,ht_container
      kibuvits_krl171bt4_typecheck bn, String,s_expected_version
      kibuvits_krl171bt4_typecheck bn, [NilClass,String],s_optional_error_message_suffix
   end # if
   if !(ht_container.has_key? $kibuvits_krl171bt4_lc_s_version)
      s_varname=kibuvits_krl171bt4_s_varvalue2varname(a_binding, ht_container)
      msg=nil
      if 0<s_varname.length
         msg="The "+s_varname+" is missing the key, \""
      else
         msg="The ht_container is missing the key, \""
      end # if
      msg=msg+$kibuvits_krl171bt4_lc_s_version+"\", that refers to the version number."
      if s_optional_error_message_suffix!=nil
         msg=msg+("\n"+s_optional_error_message_suffix)
      end # if
      kibuvits_krl171bt4_throw(msg,a_binding)
   end # if
   s_version=ht_container[$kibuvits_krl171bt4_lc_s_version]
   if s_version!=s_expected_version
      s_varname=kibuvits_krl171bt4_s_varvalue2varname(a_binding,ht_container)
      msg=nil
      if 0<s_varname.length
         msg=s_varname+"[\""+$kibuvits_krl171bt4_lc_s_version+"\"]==\""+s_version+"\", but \""+
         s_expected_version+"\" was expected."
      else
         msg="ht_container[\""+$kibuvits_krl171bt4_lc_s_version+"\"]==\""+s_version+"\", but \""+
         s_expected_version+"\" was expected."
      end # if
      if s_optional_error_message_suffix!=nil
         msg=msg+("\n"+s_optional_error_message_suffix)
      end # if
      kibuvits_krl171bt4_throw(msg,a_binding)
   end # if
end

#kibuvits_krl171bt4_assert_ht_has_keys(a_binding, ht, x_key_candidate_or_ar_of_key_candidates, s_optional_error_message_suffix = nil) ⇒ Object

This function has a limitation that if a single array is expected to be the key of the hashtable, then it has to be wrapped into an array. That is to say:

Wrong: kibuvits_krl171bt4_assert_ht_has_keys(binging(),ht,array_as_a_key_candidate)

Correct: kibuvits_krl171bt4_assert_ht_has_keys(binging(),ht,[array_as_a_key_candidate])


1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 1044

def kibuvits_krl171bt4_assert_ht_has_keys(a_binding,ht,
   x_key_candidate_or_ar_of_key_candidates,
   s_optional_error_message_suffix=nil)
   if KIBUVITS_krl171bt4_b_DEBUG
      # The typechecks are within the KIBUVITS_krl171bt4_b_DEBUG
      # block due to a fact that sometimes one might
      # want to use the assert clause even, if the
      # debug mode has been switched off.
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, Binding,a_binding
      kibuvits_krl171bt4_typecheck bn, Hash,ht
      kibuvits_krl171bt4_typecheck bn, [NilClass,String],s_optional_error_message_suffix
   end # if
   x_missing_keys=nil
   if x_key_candidate_or_ar_of_key_candidates.class==Array
      x_key_candidate_or_ar_of_key_candidates.each do |x_key_candidate|
         if !ht.has_key? x_key_candidate
            x_missing_keys=Array.new if x_missing_keys.class!=Array
            x_missing_keys<<x_key_candidate
         end # if
      end # loop
   else
      return if ht.has_key? x_key_candidate_or_ar_of_key_candidates
      x_missing_keys=[x_key_candidate_or_ar_of_key_candidates]
   end # if
   return if x_missing_keys.class==NilClass
   # It's actually legitimate for the instance to
   # miss a variable, designating symbol, within the scope that
   # the a_binding references, because the instance
   # might have been referenced by an object id or by some
   # other way by using reflection or fed in like
   # kibuvits_krl171bt4_assert_ht_keys_and(binding(), an_awesome_function(),"a_key_candidate")
   #
   # Speed-optimizing exception throwing speeds up selftests, though, I
   # understand that due to string instantiation alone the single array instantiation
   # in this method is totally irrelevant, marginal. :-D
   ar_tmp_for_speed=Array.new
   s_ht_varname=kibuvits_krl171bt4_s_varvalue2varname(a_binding,ht,ar_tmp_for_speed)
   msg=nil
   if s_ht_varname.length==0
      msg="\nThe hashtable is missing the following keys:\n"
   else
      msg="\nThe hashtable, "+s_ht_varname+", is missing the following keys:\n"
   end # if
   b_comma_needed=false
   s_1=", "
   s_2=nil
   x_missing_keys.each  do |x_key|
      if b_comma_needed
         s_2=s_1+x_key.to_s # to use shorter temporary strings
         msg=msg+s_2
      else
         msg=msg+x_key.to_s
         b_comma_needed=true
      end # if
   end # loop
   msg=msg+$kibuvits_krl171bt4_lc_linebreak
   if s_optional_error_message_suffix.class==String
      s_2=s_optional_error_message_suffix+$kibuvits_krl171bt4_lc_linebreak
      msg=msg+s_2
   end # if
   kibuvits_krl171bt4_set_var_in_scope(a_binding,
   "kibuvits_krl171bt4_assert_ht_has_keys_s_msg",msg,ar_tmp_for_speed)
   eval("kibuvits_krl171bt4_throw(kibuvits_krl171bt4_assert_ht_has_keys_s_msg)\n",a_binding)
end

#kibuvits_krl171bt4_assert_ht_has_keyvaluepairs_s(a_binding, ht, ar_keyvaluepair_or_ar_keyvaluepairs, s_optional_error_message_suffix = nil) ⇒ Object


The keys and values must all be of class String. Usage example:

ht=Hash.new ht=“there” ht=“to heaven” ht=“day” ht=“other string value”

a_binding=binding()

# A single compulsory key-value pair: kibuvits_krl171bt4_assert_ht_has_keyvaluepairs_s(a_binding,ht,)

# Multiple compulsory key-value pairs: kibuvits_krl171bt4_assert_ht_has_keyvaluepairs_s(a_binding,ht, [[“hi“,”there“],])



1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 1129

def kibuvits_krl171bt4_assert_ht_has_keyvaluepairs_s(a_binding,ht,
   ar_keyvaluepair_or_ar_keyvaluepairs,
   s_optional_error_message_suffix=nil)
   if KIBUVITS_krl171bt4_b_DEBUG
      # The typechecks are within the KIBUVITS_krl171bt4_b_DEBUG
      # block due to a fact that sometimes one might
      # want to use the assert clause even, if the
      # debug mode has been switched off.
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, Binding,a_binding
      kibuvits_krl171bt4_typecheck bn, Hash,ht
      kibuvits_krl171bt4_typecheck bn, Array,ar_keyvaluepair_or_ar_keyvaluepairs
      kibuvits_krl171bt4_typecheck bn, [NilClass,String],s_optional_error_message_suffix
      if ar_keyvaluepair_or_ar_keyvaluepairs.size==0
         kibuvits_krl171bt4_throw("ar_keyvaluepair_or_ar_keyvaluepairs.size==0\n")
      end # if
      x_keyvaluepair_or_key=ar_keyvaluepair_or_ar_keyvaluepairs[0]
      kibuvits_krl171bt4_typecheck bn, [String,Array],x_keyvaluepair_or_key
   else
      if ar_keyvaluepair_or_ar_keyvaluepairs.size==0
         # I know that it duplicates the debug branch,
         # but I can not refactor it out of here.
         kibuvits_krl171bt4_throw("ar_keyvaluepair_or_ar_keyvaluepairs.size==0\n")
      end # if
   end # if
   ar_keyvaluepairs=nil
   if (ar_keyvaluepair_or_ar_keyvaluepairs[0]).class==Array
      ar_keyvaluepairs=ar_keyvaluepair_or_ar_keyvaluepairs
   else
      ar_keyvaluepairs=[ar_keyvaluepair_or_ar_keyvaluepairs]
   end # if
   s_key=nil
   s_value=nil
   x_key_is_missing=nil
   if KIBUVITS_krl171bt4_b_DEBUG
      ar_keyvaluepairs.each do |ar_keyvaluepair|
         bn=binding()
         kibuvits_krl171bt4_typecheck bn, Array,ar_keyvaluepair
         if ar_keyvaluepair.size!=2
            kibuvits_krl171bt4_throw("2!=ar_keyvaluepair.size=="+
            ar_keyvaluepair.size.to_s)
         end # if
         s_key=ar_keyvaluepair[0]
         s_value=ar_keyvaluepair[1]
         kibuvits_krl171bt4_typecheck bn, String,s_key
         kibuvits_krl171bt4_typecheck bn, String,s_value
         if !ht.has_key? s_key
            x_key_is_missing=true
            break
         end # if
         if ht[s_key]!=s_value
            x_key_is_missing=false
            break
         end # if
      end # loop
   else
      ar_keyvaluepairs.each do |ar_keyvaluepair|
         s_key=ar_keyvaluepair[0]
         s_value=ar_keyvaluepair[1]
         if !ht.has_key? s_key
            x_key_is_missing=true
            break
         end # if
         if ht[s_key]!=s_value
            x_key_is_missing=false
            break
         end # if
      end # loop
   end # if
   return if x_key_is_missing.class==NilClass
   ar_tmp_for_speed=Array.new
   s_ht_name=kibuvits_krl171bt4_s_varvalue2varname(a_binding,ht,ar_tmp_for_speed)
   msg=nil
   if x_key_is_missing==true
      if 0<s_ht_name.length
         msg="The hashtable, "+s_ht_name+
         ", is missing a key named \""+s_key+"\"."
      else
         msg="The hashtable is missing a key named \""+s_key+"\"."
      end # if
   else # x_key_is_missing==false
      if 0<s_ht_name.length
         msg=s_ht_name+"[\""+s_key+"\"]=="+ht[s_key]+"!="+s_value
      else
         msg="<a hashtable>[\""+s_key+"\"]=="+ht[s_key]+"!="+s_value
      end # if
   end # if
   msg=msg+$kibuvits_krl171bt4_lc_linebreak
   kibuvits_krl171bt4_set_var_in_scope(a_binding,
   "kibuvits_krl171bt4_assert_ht_has_keyvaluepairs_s_msg",msg,ar_tmp_for_speed)
   eval("kibuvits_krl171bt4_throw(kibuvits_krl171bt4_assert_ht_has_keyvaluepairs_s_msg)\n",
   a_binding)
end

#kibuvits_krl171bt4_assert_is_among_values(a_binding, ob_or_ar_or_ht, ob, s_optional_error_message_suffix = nil) ⇒ Object

If the ob_or_ar_or_ht is an Array or a hashtable(Hash),then the ob is compared with the content of the Array or the values of the hashtable.



1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 1697

def kibuvits_krl171bt4_assert_is_among_values(a_binding,ob_or_ar_or_ht,
   ob,s_optional_error_message_suffix=nil)
   ar_values=nil
   if ob_or_ar_or_ht.class==Array
      ar_values=ob_or_ar_or_ht
   else
      if ob_or_ar_or_ht.class==Hash
         ar_values=ob_or_ar_or_ht.values
      else
         ar_values=[ob_or_ar_or_ht]
      end # if
   end # if
   b_throw=true
   ar_values.each do |x_value|
      if ob==x_value
         b_throw=false
         break
      end # if
   end # loop
   if b_throw
      b_list_assembleable=true
      ar_values.each do |x_value|
         cl=x_value.class
         if (cl!=String)&&(cl!=Integer)&&(cl!=Rational)&&(cl!=Bignum)&&(cl!=Fixnum)
            b_list_assembleable=false
            break
         end # if
      end # loop
      s_varname=kibuvits_krl171bt4_s_varvalue2varname(a_binding,ob)
      s_varname="<an object>" if s_varname.length==0
      msg=$kibuvits_krl171bt4_lc_doublelinebreak+s_varname+
      " does not have a value that is among the set of valid values. \n"+
      s_varname+"=="+ob.to_s
      if b_list_assembleable
         b_nonfirst=false
         s_list=$kibuvits_krl171bt4_lc_emptystring
         ar_values.each do |x_value|
            s_list=s_list+", " if b_nonfirst
            b_nonfirst=true
            s_list=s_list+x_value.to_s
         end # loop
         msg=msg+"\nList of valid values: "+s_list+".\n"
      end # if
      if s_optional_error_message_suffix.class==String
         msg=msg+"\n"+s_optional_error_message_suffix
      end # if
      msg=msg+$kibuvits_krl171bt4_lc_doublelinebreak
      kibuvits_krl171bt4_throw(msg,a_binding)
   end # if
end

#kibuvits_krl171bt4_assert_is_inherited_from_and_does_not_equal_with_class(a_binding, ob, cl_or_s_class, s_optional_error_message_suffix = nil) ⇒ Object

kibuvits_krl171bt4_assert_is_inherited_from_or_equals_with_class



1687
1688
1689
1690
1691
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 1687

def kibuvits_krl171bt4_assert_is_inherited_from_and_does_not_equal_with_class(a_binding,ob,
   cl_or_s_class,s_optional_error_message_suffix=nil)
   kibuvits_krl171bt4_impl_class_inheritance_assertion_funcs_t1(
   a_binding,ob,cl_or_s_class,false,s_optional_error_message_suffix)
end

#kibuvits_krl171bt4_assert_is_inherited_from_or_equals_with_class(a_binding, ob, cl_or_s_class, s_optional_error_message_suffix = nil) ⇒ Object

kibuvits_krl171bt4_impl_class_inheritance_assertion_funcs_t1



1681
1682
1683
1684
1685
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 1681

def kibuvits_krl171bt4_assert_is_inherited_from_or_equals_with_class(a_binding,ob,
   cl_or_s_class,s_optional_error_message_suffix=nil)
   kibuvits_krl171bt4_impl_class_inheritance_assertion_funcs_t1(
   a_binding,ob,cl_or_s_class,true,s_optional_error_message_suffix)
end

#kibuvits_krl171bt4_assert_is_smaller_than_or_equal_to(a_binding, i_or_fd_or_ar_or_i_or_fd, i_or_fd_or_ar_of_i_or_fd_upper_bounds, s_optional_error_message_suffix = nil) ⇒ Object




1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 1750

def kibuvits_krl171bt4_assert_is_smaller_than_or_equal_to(a_binding,
   i_or_fd_or_ar_or_i_or_fd, i_or_fd_or_ar_of_i_or_fd_upper_bounds,
   s_optional_error_message_suffix=nil)
   # TODO: create additional methods
   #       assert_monotonic_increase_t1(ar_series_in),
   #       assert_monotonic_decrease_t1(ar_series_in)
   ar_allowed_classes=[Integer,Bignum,Fixnum,Float,Rational]
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      ar_x=(ar_allowed_classes+[Array])
      kibuvits_krl171bt4_typecheck bn, Binding, a_binding
      kibuvits_krl171bt4_typecheck bn, ar_x, i_or_fd_or_ar_or_i_or_fd
      kibuvits_krl171bt4_typecheck bn, ar_x, i_or_fd_or_ar_of_i_or_fd_upper_bounds
      kibuvits_krl171bt4_typecheck bn, [NilClass,String], s_optional_error_message_suffix
   end # if

   ar_values=nil
   if i_or_fd_or_ar_or_i_or_fd.class==Array
      ar_values=i_or_fd_or_ar_or_i_or_fd
   else
      ar_values=[i_or_fd_or_ar_or_i_or_fd]
   end # if

   ar_upper_bounds=nil
   if i_or_fd_or_ar_of_i_or_fd_upper_bounds.class==Array
      ar_upper_bounds=i_or_fd_or_ar_of_i_or_fd_upper_bounds
   else
      ar_upper_bounds=[i_or_fd_or_ar_of_i_or_fd_upper_bounds]
   end # if

   #------------------------------------------------------------
   # If the types in the array are wrong, then it's
   # probable that the values of those elements, that have
   # a correct type, are also wrong. It's better to
   # throw before doing any calculations with the faulty
   # values and throw at some other, more distant, place.
   # That explains the existence of this, extra, typechecking loop.
   s_suffix="\nGUID='2c3df6c9-020f-472e-8454-c13290a118e7'"
   if s_optional_error_message_suffix!=nil
      s_suffix=(s_suffix+$kibuvits_krl171bt4_lc_linebreak)+s_optional_error_message_suffix
   end # if
   s_optional_error_message_suffix
   ar_values.each do |x_value|
      kibuvits_krl171bt4_typecheck(a_binding,ar_allowed_classes,x_value,s_suffix)
   end # loop
   #---------------------
   s_suffix="\nGUID='a664894a-3675-4501-9424-c13290a118e7'"
   if s_optional_error_message_suffix!=nil
      s_suffix=(s_suffix+$kibuvits_krl171bt4_lc_linebreak)+s_optional_error_message_suffix
   end # if
   s_optional_error_message_suffix
   ar_upper_bounds.each do |x_value|
      kibuvits_krl171bt4_typecheck(a_binding,ar_allowed_classes,x_value,s_suffix)
   end # loop
   #------------------------------------------------------------
   b_throw=false
   x_elem=nil
   x_upper_bound_0=nil
   ar_values.each do |x_value|
      ar_upper_bounds.each do |x_upper_bound|
         if x_upper_bound<x_value
            x_upper_bound_0=x_upper_bound
            x_elem=x_value
            b_throw=true
            break
         end # if
      end # loop
      break if b_throw
   end # loop
   if b_throw
      s_0=" == "
      s_varname_1=kibuvits_krl171bt4_s_varvalue2varname(a_binding,x_upper_bound_0)
      if s_varname_1.length==0 # Includes a case, where a numeric constant is an input
         # Emtpystring.
      else
         s_varname_1<<s_0
      end # if
      s_varname_2=kibuvits_krl171bt4_s_varvalue2varname(a_binding,x_elem)
      if s_varname_2.length==0 # Includes a case, where a numeric constant is an input
         # Emtpystring.
      else
         s_varname_2<<s_0
      end # if
      msg=$kibuvits_krl171bt4_lc_doublelinebreak+s_varname_1+x_upper_bound_0.to_s+
      " < " + s_varname_2 + x_elem.to_s+
      "\nGUID='47e8cd25-3f02-4621-a204-c13290a118e7'"
      if s_optional_error_message_suffix.class==String
         msg=msg+"\n"+s_optional_error_message_suffix
      end # if
      msg=msg+$kibuvits_krl171bt4_lc_doublelinebreak
      kibuvits_krl171bt4_throw(msg,a_binding)
   end # if
end

#kibuvits_krl171bt4_assert_ok_to_be_a_varname_t1(a_binding, s_in, s_optional_error_message_suffix = nil) ⇒ Object

kibuvits_krl171bt4_b_not_suitable_for_a_varname_t1



1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 1328

def kibuvits_krl171bt4_assert_ok_to_be_a_varname_t1(a_binding,s_in,
   s_optional_error_message_suffix=nil)
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, Binding, a_binding
      kibuvits_krl171bt4_typecheck bn, String, s_in
      kibuvits_krl171bt4_typecheck bn, [NilClass,String],s_optional_error_message_suffix
   end # if
   if kibuvits_krl171bt4_b_not_suitable_for_a_varname_t1(s_in)
      s_varname=kibuvits_krl171bt4_s_varvalue2varname(a_binding,s_in)
      kibuvits_krl171bt4_throw("\n"+s_varname+"==\""+s_in.to_s+
      "\" is not suitable for a variable name. \n",a_binding)
   end # if
end

#kibuvits_krl171bt4_assert_responds_2_method(a_binding, ob, x_method_name_or_method_or_symbol, s_optional_error_message_suffix = nil) ⇒ Object




1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 1569

def kibuvits_krl171bt4_assert_responds_2_method(a_binding,ob,
   x_method_name_or_method_or_symbol,
   s_optional_error_message_suffix=nil)
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, Binding,a_binding
      kibuvits_krl171bt4_typecheck bn, [String,Method,Symbol],x_method_name_or_method_or_symbol
      kibuvits_krl171bt4_typecheck bn, [NilClass,String],s_optional_error_message_suffix
   end # if
   sym_x=nil
   s_clname=x_method_name_or_method_or_symbol.class.to_s
   case s_clname
   when $kibuvits_krl171bt4_lc_s_String
      bn=binding()
      kibuvits_krl171bt4_assert_string_min_length(bn,x_method_name_or_method_or_symbol,1)
      sym_x=x_method_name_or_method_or_symbol.to_sym
   when $kibuvits_krl171bt4_lc_s_Method
      sym_x=x_method_name_or_method_or_symbol.name
   when $kibuvits_krl171bt4_lc_s_Symbol
      sym_x=x_method_name_or_method_or_symbol
   else
      kibuvits_krl171bt4_throw("There's a flaw. 26022333-bfa5-44a8-8c02-03e150913cd7")
   end # case x_method_name_or_method_or_symbol.class
   if !ob.respond_to? sym_x
      s_varname=kibuvits_krl171bt4_s_varvalue2varname(a_binding,ob)
      s_varname="<an object>" if s_varname.length==0
      msg=s_varname+" is expected to have a method named \""+
      sym_x.to_s+"\", but it does not have it. "
      if s_optional_error_message_suffix.class==String
         msg=msg+s_optional_error_message_suffix
      end # if
      kibuvits_krl171bt4_throw(msg,a_binding)
   end # if
end

#kibuvits_krl171bt4_assert_string_min_length(a_binding, s_in, i_min_length, s_optional_error_message_suffix = nil) ⇒ Object




1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 1255

def kibuvits_krl171bt4_assert_string_min_length(a_binding,s_in,i_min_length,
   s_optional_error_message_suffix=nil)
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, Binding, a_binding
      kibuvits_krl171bt4_typecheck bn, String, s_in
      kibuvits_krl171bt4_typecheck bn, [Integer,Fixnum,Bignum], i_min_length
      kibuvits_krl171bt4_typecheck bn, [NilClass,String],s_optional_error_message_suffix
      if i_min_length<0
         kibuvits_krl171bt4_throw("i_min_length == "+i_min_length.to_s+" < 0");
      end # if
   end # if
   i_len=s_in.length
   if i_len<i_min_length
      s_varname=kibuvits_krl171bt4_s_varvalue2varname(a_binding,s_in)
      s_varname="<a string>" if s_varname.length==0
      kibuvits_krl171bt4_throw(s_varname+".length=="+i_len.to_s+", but the "+
      "minimum allowed string length is "+i_min_length.to_s+".",a_binding)
   end # if
end

#kibuvits_krl171bt4_b_class_defined?(s_or_sym_or_cl_class_name) ⇒ Boolean

kibuvits_krl171bt4_b_class_defined_helperfunc_update_ht_objects

Returns:

  • (Boolean)


2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 2097

def kibuvits_krl171bt4_b_class_defined?(s_or_sym_or_cl_class_name)
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, [Symbol,String,Class], s_or_sym_or_cl_class_name
   end # if
   s_class_name_in=s_or_sym_or_cl_class_name.to_s
   if @kibuvits_krl171bt4_b_class_defined_cache_ht_objects==nil
      kibuvits_krl171bt4_b_class_defined_helperfunc_update_ht_objects()
   else
      # The list of defined classes can grow between the calls
      # to the kibuvits_krl171bt4_b_class_defined?
      if !@kibuvits_krl171bt4_b_class_defined_cache_ht_objects.has_key? s_class_name_in
         kibuvits_krl171bt4_b_class_defined_helperfunc_update_ht_objects()
      end # if
   end # if
   b_out=@kibuvits_krl171bt4_b_class_defined_cache_ht_objects.has_key?(s_class_name_in)
   return b_out
end

#kibuvits_krl171bt4_b_class_defined_helperfunc_update_ht_objectsObject



2087
2088
2089
2090
2091
2092
2093
2094
2095
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 2087

def kibuvits_krl171bt4_b_class_defined_helperfunc_update_ht_objects
   ht_objects=Hash.new
   ObjectSpace.each_object do |ob|
      if ob.class==Class
         ht_objects[ob.to_s]=ob
      end # if
   end # loop
   @kibuvits_krl171bt4_b_class_defined_cache_ht_objects=ht_objects
end

#kibuvits_krl171bt4_b_contains_common_special_characters_t1(s_in) ⇒ Object

It’s tested as part of the kibuvits_krl171bt4_assert_does_not_contain_common_special_characters_t1



1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 1303

def kibuvits_krl171bt4_b_contains_common_special_characters_t1(s_in)
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, String, s_in
   end # if
   i_0=s_in.length
   return false if i_0==0
   s_1=s_in.gsub(/[\t\s\n\r;:|,.$<>+\-%*~\/\[\](){}\\^'"]/,$kibuvits_krl171bt4_lc_emptystring)
   return true if s_1.length!=i_0
   return false
end

#kibuvits_krl171bt4_b_not_a_whole_number_t1(x_in) ⇒ Object




1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 1846

def kibuvits_krl171bt4_b_not_a_whole_number_t1(x_in)
   cl=x_in.class
   return false if cl==Integer
   return false if cl==Bignum
   return false if cl==Fixnum
   if cl==String
      return true if x_in.length==0
      s_0=x_in.sub(/^[-]?[\d]+$/,$kibuvits_krl171bt4_lc_emptystring)
      return false if s_0.length==0
      return true
   end # if
   if (cl==Float)||(cl==Rational)
      fd_0=x_in.abs
      fd_1=fd_0-(fd_0.floor)
      b_out=(fd_1!=0)
      return b_out
   end # if
   return true
end

#kibuvits_krl171bt4_b_not_suitable_for_a_varname_t1(s_in) ⇒ Object

kibuvits_krl171bt4_b_contains_common_special_characters_t1



1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 1315

def kibuvits_krl171bt4_b_not_suitable_for_a_varname_t1(s_in)
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, String, s_in
   end # if
   i_0=s_in.length
   return true if i_0==0
   return true if kibuvits_krl171bt4_b_contains_common_special_characters_t1(s_in)
   s_1=s_in.gsub(/^[\d]/,$kibuvits_krl171bt4_lc_emptystring)
   return true if s_in.length!=s_1.length
   return false
end

#kibuvits_krl171bt4_block_throwsObject

Returns a boolean value.



2190
2191
2192
2193
2194
2195
2196
2197
2198
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 2190

def kibuvits_krl171bt4_block_throws
   answer=false;
   begin
      yield
   rescue Exception => e
      answer=true
   end # rescue
   return answer
end

#kibuvits_krl171bt4_call_by_ar_of_args(ob, x_method_name_or_symbol, ar_method_arguments, &block) ⇒ Object




1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 1925

def kibuvits_krl171bt4_call_by_ar_of_args(ob,x_method_name_or_symbol,ar_method_arguments,&block)
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, [Symbol,String],x_method_name_or_symbol

      # The ar_method_arguments must not be nil, because otherwise
      # one could call just ob.send(:methodname_as_symbol,block),
      # which is considerably faster than this function here.
      kibuvits_krl171bt4_typecheck bn, Array,ar_method_arguments
      kibuvits_krl171bt4_typecheck bn, [NilClass,Proc],block
   end # if
   x_sym=x_method_name_or_symbol
   x_sym=x_sym.to_sym if x_sym.class==String
   ar_args=ar_method_arguments
   i_len=ar_args.size
   x_out=nil
   # The case-clauses are due to speed optimization.
   if block==nil
      case i_len
      when 0
         x_out=ob.send(x_sym)
      when 1
         x_out=ob.send(x_sym,ar_args[0])
      when 2
         x_out=ob.send(x_sym,ar_args[0],ar_args[1])
      when 3
         x_out=ob.send(x_sym,ar_args[0],ar_args[1],ar_args[2])
      when 4
         x_out=ob.send(x_sym,ar_args[0],ar_args[1],ar_args[2],
         ar_args[3])
      when 5
         x_out=ob.send(x_sym,ar_args[0],ar_args[1],ar_args[2],
         ar_args[3],ar_args[4])
      when 6
         x_out=ob.send(x_sym,ar_args[0],ar_args[1],ar_args[2],
         ar_args[3],ar_args[4],ar_args[5])
      when 7
         x_out=ob.send(x_sym,ar_args[0],ar_args[1],ar_args[2],
         ar_args[3],ar_args[4],ar_args[5],ar_args[6])
      else
         ar_in=[ob,x_sym,ar_args]
         s_script="ob=ar_in[0];x_sym=ar_in[1];ar_args=ar_in[2];"+
         "x_out=ob.send(x_sym"
         s_lc_1=",ar_args["
         i_len.times do |i|
            s_script=s_script+(s_lc_1+(i.to_s+$kibuvits_krl171bt4_lc_rsqbrace))
         end # loop
         s_script=s_script+($kibuvits_krl171bt4_lc_rbrace+"; ar_out<<x_out")
         ar_out=kibuvits_krl171bt4_eval_t1(s_script, ar_in)
         x_out=ar_out[0]
      end # case i_len
   else
      case i_len
      when 0
         x_out=ob.send(x_sym,&block)
      when 1
         x_out=ob.send(x_sym,ar_args[0],&block)
      when 2
         x_out=ob.send(x_sym,ar_args[0],ar_args[1],&block)
      when 3
         x_out=ob.send(x_sym,ar_args[0],ar_args[1],ar_args[2],&block)
      when 4
         x_out=ob.send(x_sym,ar_args[0],ar_args[1],ar_args[2],
         ar_args[3],&block)
      when 5
         x_out=ob.send(x_sym,ar_args[0],ar_args[1],ar_args[2],
         ar_args[3],ar_args[4],&block)
      when 6
         x_out=ob.send(x_sym,ar_args[0],ar_args[1],ar_args[2],
         ar_args[3],ar_args[4],ar_args[5],&block)
      when 7
         x_out=ob.send(x_sym,ar_args[0],ar_args[1],ar_args[2],
         ar_args[3],ar_args[4],ar_args[5],ar_args[6],&block)
      else
         ar_in=[ob,x_sym,ar_args,block]
         s_script=$kibuvits_krl171bt4_lc_emptystring+
         "ob=ar_in[0];x_sym=ar_in[1];ar_args=ar_in[2];block=ar_in[3];"+
         "x_out=ob.send(x_sym"
         s_lc_1=",ar_args["
         i_len.times do |i|
            s_script=s_script+(s_lc_1+(i.to_s+$kibuvits_krl171bt4_lc_rsqbrace))
         end # loop
         s_script=s_script+(",&block); ar_out<<x_out")
         ar_out=kibuvits_krl171bt4_eval_t1(s_script, ar_in)
         x_out=ar_out[0]
      end # case i_len
   end # if
   return x_out
end

#kibuvits_krl171bt4_combination(i_superset_size, i_subset_size) ⇒ Object

kibuvits_krl171bt4_combinatorical_variation



18026
18027
18028
18029
18030
18031
18032
18033
18034
18035
18036
18037
18038
18039
18040
18041
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 18026

def kibuvits_krl171bt4_combination(i_superset_size,i_subset_size)
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      # Allowing the i_n to be a Bignum is a bit crazy, but it's not wrong.
      kibuvits_krl171bt4_typecheck bn, [Fixnum,Bignum], i_superset_size
      kibuvits_krl171bt4_typecheck bn, [Fixnum,Bignum], i_subset_size
      kibuvits_krl171bt4_assert_is_smaller_than_or_equal_to(bn,0,i_subset_size,
      "\n GUID='e4696745-7cd5-42c4-a416-c13290a118e7'\n\n")
      kibuvits_krl171bt4_assert_is_smaller_than_or_equal_to(bn,i_subset_size,i_superset_size,
      "\n GUID='11fe5833-91a0-4498-b2e5-c13290a118e7'\n\n")
   end # if
   i_var=kibuvits_krl171bt4_combinatorical_variation(
   i_superset_size,i_subset_size)
   i_c=i_var/kibuvits_krl171bt4_factorial(i_subset_size)
   return i_c
end

#kibuvits_krl171bt4_combinatorical_variation(i_superset_size, i_subset_size) ⇒ Object

kibuvits_krl171bt4_factorial



18009
18010
18011
18012
18013
18014
18015
18016
18017
18018
18019
18020
18021
18022
18023
18024
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 18009

def kibuvits_krl171bt4_combinatorical_variation(i_superset_size,i_subset_size)
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      # Allowing the i_n to be a Bignum is a bit crazy, but it's not wrong.
      kibuvits_krl171bt4_typecheck bn, [Fixnum,Bignum], i_superset_size
      kibuvits_krl171bt4_typecheck bn, [Fixnum,Bignum], i_subset_size
      kibuvits_krl171bt4_assert_is_smaller_than_or_equal_to(bn,0,i_subset_size,
      "\n GUID='3682f292-a16b-44ad-a846-c13290a118e7'\n\n")
      kibuvits_krl171bt4_assert_is_smaller_than_or_equal_to(bn,i_subset_size,i_superset_size,
      "\n GUID='15978c51-c4e7-4668-8226-c13290a118e7'\n\n")
   end # if
   i_0=kibuvits_krl171bt4_factorial(i_superset_size)
   i_1=kibuvits_krl171bt4_factorial(i_superset_size-i_subset_size)
   i_var=i_0/i_1
   return i_var
end

#kibuvits_krl171bt4_eval_t1(s_script, ar_in = nil) ⇒ Object

If the ar_in!=nil, then it is sent to the scope of the s_script. The s_script is expected to place its output to an array named ar_out.

Both, the ar_in and the ar_out are allocated outside of the scope of the s_script, that is to say, the s_script must not reinstantiate the ar_in and ar_out.

The kibuvits_krl171bt4_eval_t1(…) returns the ar_out.



1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 1883

def kibuvits_krl171bt4_eval_t1(s_script, ar_in=nil)
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, String,s_script
      kibuvits_krl171bt4_typecheck bn, [NilClass,Array],ar_in
      rgx_ar_in=/([\s]|^|[;])ar_in[\s]*=[\s]*(\[|Array[.])/
      # Actually the rgx_ar_in does not
      # cover cases like ar_in<<x
      # ar_in[i]=x; ar_in.clear;  etc.
      if s_script.match(rgx_ar_in)!=nil
         kibuvits_krl171bt4_throw("The s_script seems to contain "+
         "something like ar_in=Array.new or ar_in=[] or something "+
         "similar. To avoid side-effects the ar_in must "+
         "not be modified within the s_script.")
      end # if
      rgx_ar_out=/([\s]|^|[;])ar_out[\s]*=[\s]*(\[|Array[.])/
      if s_script.match(rgx_ar_out)!=nil
         kibuvits_krl171bt4_throw("The s_script seems to contain "+
         "something like ar_out=Array.new or ar_out=[] or something "+
         "similar. The ar_out must not be reinstantiated within "+
         "the s_script, because the ar_out instance is used for "+
         "retrieving the ar_out content from the s_script scope.")
      end # if
   end # if
   ar_out=Array.new
   s_scr=nil
   if ar_in!=nil
      s_scr=$kibuvits_krl171bt4_lc_kibuvits_krl171bt4_eval_t1_s1+
      (ar_in.object_id.to_s+$kibuvits_krl171bt4_lc_rbrace_linebreak)
   else
      s_scr=$kibuvits_krl171bt4_lc_emptystring
   end # if
   s_scr=s_scr+($kibuvits_krl171bt4_lc_kibuvits_krl171bt4_eval_t1_s2+
   (ar_out.object_id.to_s+$kibuvits_krl171bt4_lc_rbrace_linebreak))
   s_scr=s_scr+s_script
   eval(s_scr)
   return ar_out
end

#kibuvits_krl171bt4_exc_class_name_2_cl(s_or_sym_or_cl_class_name) ⇒ Object

Throws, if the class is not defined.



2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 2117

def kibuvits_krl171bt4_exc_class_name_2_cl(s_or_sym_or_cl_class_name)
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, [Symbol,String,Class], s_or_sym_or_cl_class_name
   end # if
   s_class_name_in=s_or_sym_or_cl_class_name.to_s
   if @kibuvits_krl171bt4_b_class_defined_cache_ht_objects==nil
      kibuvits_krl171bt4_b_class_defined_helperfunc_update_ht_objects()
   end # if
   if !kibuvits_krl171bt4_b_class_defined? s_class_name_in
      kibuvits_krl171bt4_throw("\nClass named \""+
      s_class_name_in+"\" has not been loaded.\n"+
      "There does exist a possibility that if the current exception \n"+
      "were not thrown, it might be loaded after the \n"+
      "call to the function kibuvits_krl171bt4_exc_class_name_2_cl(...).\n")
   end # if
   cl_out=@kibuvits_krl171bt4_b_class_defined_cache_ht_objects[s_class_name_in]
   return cl_out
end

#kibuvits_krl171bt4_factorial(i_n) ⇒ Object

class Kibuvits_krl171bt4_numerics_set_0



18004
18005
18006
18007
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 18004

def kibuvits_krl171bt4_factorial(i_n)
   i_out=Kibuvits_krl171bt4_numerics_set_0.i_factorial_t1(i_n)
   return i_out
end

#kibuvits_krl171bt4_file2str(s_file_path) ⇒ Object



6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 6738

def kibuvits_krl171bt4_file2str(s_file_path)
   s_out=$kibuvits_krl171bt4_lc_emptystring
   if KIBUVITS_krl171bt4_RUBY_LIBRARY_IS_AVAILABLE
      if KIBUVITS_krl171bt4_b_DEBUG
         bn=binding()
         kibuvits_krl171bt4_typecheck bn, String, s_file_path
      end # if
   end # if
   $kibuvits_krl171bt4_lc_mx_streamaccess.synchronize do
      # The idea here is to make the file2str easily copy-pastable to projects that
      # do not use the Kibuvits Ruby Library.
      s_fp=s_file_path
      ar_lines=Array.new
      begin
         File.open(s_fp,'r') do |file|
            while line = file.gets
               ar_lines<<$kibuvits_krl171bt4_lc_emptystring+line
            end # while
         end # Open-file region.
         if KIBUVITS_krl171bt4_RUBY_LIBRARY_IS_AVAILABLE
            s_out=kibuvits_krl171bt4_s_concat_array_of_strings(ar_lines)
         else
            s_out=kibuvits_krl171bt4_hack_to_break_circular_dependency_between_io_and_str_kibuvits_krl171bt4_s_concat_array_of_strings(ar_lines)
         end # if
      rescue Exception =>err
         raise(Exception.new("\n"+err.to_s+"\n\ns_file_path=="+
         s_file_path+
         "\n GUID='30eeee24-d43b-4331-b28f-c13290a118e7'\n\n"))
      end #
   end # synchronize
   return s_out
end

#kibuvits_krl171bt4_file2str_by_armour_t1(s_file_path) ⇒ Object

Reads in any file, byte-by-byte, converts the bytes to Unicode characters and returns the series of characters as a single string.



6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 6919

def kibuvits_krl171bt4_file2str_by_armour_t1(s_file_path)
   s_out=$kibuvits_krl171bt4_lc_emptystring
   if KIBUVITS_krl171bt4_RUBY_LIBRARY_IS_AVAILABLE
      if KIBUVITS_krl171bt4_b_DEBUG
         bn=binding()
         kibuvits_krl171bt4_typecheck bn, String, s_file_path
      end # if
   end # if
   ar_i=kibuvits_krl171bt4_file_2_ar_i_t1(s_file_path)
   s_out=kibuvits_krl171bt4_s_armour_t1(ar_i)
   return s_out
end

#kibuvits_krl171bt4_file_2_ar_i_t1(s_file_path) ⇒ Object

kibuvits_krl171bt4_ar_i_2_file_t1



6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 6795

def kibuvits_krl171bt4_file_2_ar_i_t1(s_file_path)
   ar_out=Array.new
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, String, s_file_path
   end # if
   s_fp=s_file_path
   $kibuvits_krl171bt4_lc_mx_streamaccess.synchronize do
      begin
         File.open(s_fp) do |file|
            file.each_byte do |i_byte|
               ar_out<<i_byte
            end # loop
         end # Open-file region.
      rescue Exception =>err
         raise(Exception.new("\n"+err.to_s+"\n\ns_file_path=="+
         s_file_path+
         "\n GUID='5c0ae815-8168-4723-a55f-c13290a118e7'\n\n"))
      end #
   end # synchronize
   return ar_out
end

#kibuvits_krl171bt4_get_binding_wrapper_instance_class(bn_caller_binding) ⇒ Object




1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 1225

def kibuvits_krl171bt4_get_binding_wrapper_instance_class(bn_caller_binding)
   ar=Array.new()
   i_ar_id=ar.object_id
   s_tmpvarname1="kibuvits_krl171bt4_get_binding_wrapper_instance_classtmpvar1"
   s_tmpvarname2="kibuvits_krl171bt4_get_binding_wrapper_instance_classtmpvar2"
   s_script=s_tmpvarname1+"=self.class\n"+
   s_tmpvarname2+"=ObjectSpace._id2ref("+i_ar_id.to_s+")\n"+
   s_tmpvarname2+"<<"+s_tmpvarname1+"\n"+
   s_tmpvarname1+"=nil\n"+
   s_tmpvarname2+"=nil\n"
   begin
      eval(s_script,bn_caller_binding)
   rescue Exception => e
      kibuvits_krl171bt4_throw ("\n\nOne of the possible causes of the "+
      "exception here is that one tried to get a class "+
      "of a static method. The workaround is that only "+
      "instances, which can be singletons, are analyzed. "+
      "There's also the limitation that one can not use the "+
      "Kibuvits_krl171bt4_msgc_stack and Kibuvits_krl171bt4_msgc instances "+
      "in functions that are not wrapped into some instance.\n\n"+
      "The caught exception message is:\n\n"+
      e.to_s+$kibuvits_krl171bt4_lc_doublelinebreak)
   end # rescue
   cl_out=ar[0]
   ar.clear
   return cl_out
end

#kibuvits_krl171bt4_hack_to_break_circular_dependency_between_io_and_str_kibuvits_krl171bt4_s_concat_array_of_strings(ar_in) ⇒ Object

It’s actually a copy of a TESTED version of kibuvits_krl171bt4_s_concat_array_of_strings and this copy here is made to avoid making the kibuvits_krl171bt4_io.rb to depend on the kibuvits_krl171bt4_str.rb



6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 6718

def kibuvits_krl171bt4_hack_to_break_circular_dependency_between_io_and_str_kibuvits_krl171bt4_s_concat_array_of_strings(ar_in)
   n=ar_in.size
   if KIBUVITS_krl171bt4_RUBY_LIBRARY_IS_AVAILABLE
      if KIBUVITS_krl171bt4_b_DEBUG
         bn=binding()
         kibuvits_krl171bt4_typecheck bn, Array, ar_in
         s=nil
         n.times do |i|
            bn=binding()
            s=ar_in[i]
            kibuvits_krl171bt4_typecheck bn, String, s
         end # loop
      end # if
   end # if
   s_out="";
   n.times{|i| s_out<<ar_in[i]}
   return s_out;
end

#kibuvits_krl171bt4_hash_plaice_t1(s_in, i_headerless_hash_length = 30, i_minimum_n_of_rounds = 40) ⇒ Object

class Kibuvits_krl171bt4_hash_plaice_t1



21238
21239
21240
21241
21242
21243
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 21238

def kibuvits_krl171bt4_hash_plaice_t1(s_in,
   i_headerless_hash_length=30,i_minimum_n_of_rounds=40)
   s_out=Kibuvits_krl171bt4_hash_plaice_t1.generate(
   s_in,i_headerless_hash_length,i_minimum_n_of_rounds)
   return s_out
end

#kibuvits_krl171bt4_impl_class_inheritance_assertion_funcs_t1(a_binding, ob, cl_or_s_class, b_classes_may_equal, s_optional_error_message_suffix) ⇒ Object




1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 1606

def kibuvits_krl171bt4_impl_class_inheritance_assertion_funcs_t1(a_binding,ob,
   cl_or_s_class,b_classes_may_equal,s_optional_error_message_suffix)
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, Binding, a_binding
      kibuvits_krl171bt4_typecheck bn, [Class,String], cl_or_s_class
      kibuvits_krl171bt4_typecheck bn, [TrueClass,FalseClass], b_classes_may_equal
      kibuvits_krl171bt4_typecheck bn, [NilClass,String], s_optional_error_message_suffix
   end # if
   cl=cl_or_s_class
   b_throw=false
   begin
      if cl_or_s_class.class==String
         cl=Kernel.const_get(cl_or_s_class)
      else
         # This branch is useful, if the KIBUVITS_krl171bt4_b_DEBUG branch is not entered.
         cl.class # throws, if it ==  <nonexisting class>.class
      end # if
   rescue Exception => e
      b_throw=true
   end # rescue
   if b_throw
      s_varname=kibuvits_krl171bt4_s_varvalue2varname(a_binding,ob)
      s_varname="<an object>" if s_varname.length==0
      msg=s_varname+" is expected to be of class "+cl_or_s_class+
      ", but the Ruby source that describes "+
      "a class with that name has not been loaded. "
      if s_optional_error_message_suffix.class==String
         msg=msg+s_optional_error_message_suffix
      end # if
      kibuvits_krl171bt4_throw(msg,a_binding)
   end # if

   if b_classes_may_equal
      if ob.class!=cl
         if !(ob.kind_of?(cl))
            s_varname=kibuvits_krl171bt4_s_varvalue2varname(a_binding,ob)
            s_varname="<an object>" if s_varname.length==0
            s_cl_name=cl_or_s_class.to_s
            msg=s_varname+".class is expected to be derived from the class "+
            s_cl_name+ ", but the "+s_varname+".class=="+ob.class.to_s+$kibuvits_krl171bt4_lc_space
            if s_optional_error_message_suffix.class==String
               msg=msg+s_optional_error_message_suffix
            end # if
            kibuvits_krl171bt4_throw(msg,a_binding)
         end # if
      end # if
   else
      if ob.class==cl
         s_varname=kibuvits_krl171bt4_s_varvalue2varname(a_binding,ob)
         s_varname="<an object>" if s_varname.length==0
         s_cl_name=cl_or_s_class.to_s
         msg=s_varname+".class is expected to differ from class "+
         s_cl_name+", but the "+s_varname+".class=="+
         ob.class.to_s+$kibuvits_krl171bt4_lc_space
         if s_optional_error_message_suffix.class==String
            msg=msg+s_optional_error_message_suffix
         end # if
         kibuvits_krl171bt4_throw(msg,a_binding)
      else
         if !(ob.kind_of?(cl))
            s_varname=kibuvits_krl171bt4_s_varvalue2varname(a_binding,ob)
            s_varname="<an object>" if s_varname.length==0
            s_cl_name=cl_or_s_class.to_s
            msg=s_varname+".class is expected to be derived from the class "+
            s_cl_name+ ", but the "+s_varname+".class=="+ob.class.to_s+$kibuvits_krl171bt4_lc_space
            if s_optional_error_message_suffix.class==String
               msg=msg+s_optional_error_message_suffix
            end # if
            kibuvits_krl171bt4_throw(msg,a_binding)
         end # if
      end # if
   end # if
end

#kibuvits_krl171bt4_s_armour_t1(ar_i) ⇒ Object

All of the numbers in the ar_i must be in range [0,255]



6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 6821

def kibuvits_krl171bt4_s_armour_t1(ar_i)
   i_len_ar_i=ar_i.size
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, Array, ar_i
      x_i=nil
      i_len_ar_i.times do |i|
         bn1=binding()
         x_i=ar_i[i]
         kibuvits_krl171bt4_typecheck bn1, Fixnum, x_i
         if x_i<0
            kibuvits_krl171bt4_throw("x_i == "+x_i.to_s+" < 0 "+
            "\n GUID='a434e13d-2bdb-40cf-b14f-c13290a118e7'\n\n")
         end # if
         if 255<x_i
            kibuvits_krl171bt4_throw(" 255 < x_i == "+x_i.to_s+
            "\n GUID='023e76f6-14e2-4acf-953f-c13290a118e7'\n\n")
         end # if
      end # loop
   end # if
   s_out=$kibuvits_krl171bt4_lc_emptystring
   # The range [A000,A48C]_hex has been chosen simply
   # because it covers a whole byte, [0,FF]_hex
   # and has an interesting language name, Yi,
   #
   # http://en.wikipedia.org/wiki/Yi_people
   # http://www.unicode.org/charts/PDF/UA000.pdf
   #
   # This way every byte can be represented by
   # a single existing Unicode character without
   # any branching, jumping, over/around Unicode "holes",
   # unassigned Unicode code points.
   #
   # A single byte is armoured as 2 byte Unicode
   # character, but this approach saves data
   # volume at later steps.
   #
   # For example, 255_base_10 is armoured to
   # 2 characters in hex, the FF_base_16, but
   # it is a single character, if armoured to Yi.
   # If the Yi characters are encrypted,
   # character-by-charcter and the number of
   # characters that the encryption function
   # returns is at least double the input data volume of the
   # encryption function, then minimizing
   # the amount of characters at armouring
   # step yields a considerable winning.
   ar_s=Array.new
   s_0=nil
   x_i=nil
   i_zero="A000".to_i(16)
   i_len_ar_i.times do |i|
      x_i=i_zero+ar_i[i]
      s_0="".concat(x_i)
      ar_s<<s_0
   end # loop
   s_out=kibuvits_krl171bt4_s_concat_array_of_strings(ar_s)
   return s_out
end

#kibuvits_krl171bt4_s_concat_array_of_strings(ar_in) ⇒ Object

Reference to the version of string concatenation function that is “usually” the fastest.



4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 4520

def kibuvits_krl171bt4_s_concat_array_of_strings(ar_in)
   # In the most frequent cases the time taken by the
   # kibuvits_krl171bt4_s_concat_array_of_strings_plain is  about 75% of the
   # time taken by the kibuvits_krl171bt4_s_concat_array_of_strings_watershed.
   # In its core mutable strings are "immutable", because they
   # have to be stretched, reallocated, from time to time like variable
   # length arrays/vectors. If the ar_in contains "huge enough" strings, then
   # it might happen that with the "huge enough" strings the
   # kibuvits_krl171bt4_s_concat_array_of_strings_watershed
   # takes less time than the plain version. As both of the functions
   # are pretty fast in terms of the absolute amount of time,
   # the watershed version is a more reliable choise.
   #
   s_out=kibuvits_krl171bt4_s_concat_array_of_strings_watershed(ar_in)
   #s_out=kibuvits_krl171bt4_s_concat_array_of_strings_plain(ar_in)
   return s_out;
end

#kibuvits_krl171bt4_s_concat_array_of_strings_plain(ar_in) ⇒ Object



4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 4351

def kibuvits_krl171bt4_s_concat_array_of_strings_plain(ar_in)
   n=ar_in.size
   if defined? KIBUVITS_krl171bt4_b_DEBUG
      if KIBUVITS_krl171bt4_b_DEBUG
         bn=binding()
         kibuvits_krl171bt4_typecheck bn, Array, ar_in
         s=nil
         n.times do |i|
            bn=binding()
            s=ar_in[i]
            kibuvits_krl171bt4_typecheck bn, String, s
         end # loop
      end # if
   end # if
   s_out="";
   n.times{|i| s_out<<ar_in[i]}
   return s_out;
end

#kibuvits_krl171bt4_s_concat_array_of_strings_watershed(ar_in) ⇒ Object

This is the main implementation of the Kibuvits Ruby Library watershed concatenation algorithm, but

Kibuvits_krl171bt4_ix.x_apply_binary_operator_t1(…)

is a commentless, general, copy of it.



4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 4378

def kibuvits_krl171bt4_s_concat_array_of_strings_watershed(ar_in)
   s_lc_emptystring=""
   if defined? KIBUVITS_krl171bt4_b_DEBUG
      if KIBUVITS_krl171bt4_b_DEBUG
         bn=binding()
         kibuvits_krl171bt4_typecheck bn, Array, ar_in
      end # if
   end # if
   i_n=ar_in.size
   if i_n<3
      if i_n==2
         s_out=ar_in[0]+ar_in[1]
         return s_out
      else
         if i_n==1
            # For the sake of consistency one
            # wants to make sure that the returned
            # string instance always differs from those
            # that are within the ar_in.
            s_out=s_lc_emptystring+ar_in[0]
            return s_out
         else # i_n==0
            s_out=s_lc_emptystring
            return s_out
         end # if
      end # if
   end # if
   s_out=s_lc_emptystring # needs to be inited to the ""

   # The classic part for testing and playing.
   # ar_in.size.times{|i| s_out=s_out+ar_in[i]}
   # return s_out

   # In its essence the rest of the code here implements
   # a tail-recursive version of this function. The idea is that
   #
   # s_out='something_very_long'.'short_string_1'.short_string_2'
   # uses a temporary string of length
   # 'something_very_long'.'short_string_1'
   # but
   # s_out='something_very_long'.('short_string_1'.short_string_2')
   # uses a much more CPU-cache friendly temporary string of length
   # 'short_string_1'.short_string_2'
   #
   # Believe it or not, but as of January 2012 the speed difference
   # in PHP can be at least about 20% and in Ruby about 50%.
   # Please do not take my word on it. Try it out yourself by
   # modifying this function and assembling strings of length
   # 10000 from single characters.
   #
   # This here is probably not the most optimal solution, because
   # within the more optimal solution the the order of
   # "concatenation glue placements" depends on the lengths
   # of the tokens/strings, but as the analysis and "gluing queue"
   # assembly also has a computational cost, the version
   # here is almost always more optimal than the totally
   # naive version.
   ar_1=ar_in
   b_ar_1_equals_ar_in=true # to avoid modifying the received Array
   ar_2=Array.new
   b_take_from_ar_1=true
   b_not_ready=true
   i_reminder=nil
   i_loop=nil
   i_ar_in_len=nil
   i_ar_out_len=0 # code after the while loop needs a number
   s_1=nil
   s_2=nil
   s_3=nil
   i_2=nil
   while b_not_ready
      # The next if-statement is to avoid copying temporary
      # strings between the ar_1 and the ar_2.
      if b_take_from_ar_1
         i_ar_in_len=ar_1.size
         i_reminder=i_ar_in_len%2
         i_loop=(i_ar_in_len-i_reminder)/2
         i_loop.times do |i|
            i_2=i*2
            s_1=ar_1[i_2]
            s_2=ar_1[i_2+1]
            s_3=s_1+s_2
            ar_2<<s_3
         end # loop
         if i_reminder==1
            s_3=ar_1[i_ar_in_len-1]
            ar_2<<s_3
         end # if
         i_ar_out_len=ar_2.size
         if 1<i_ar_out_len
            if b_ar_1_equals_ar_in
               ar_1=Array.new
               b_ar_1_equals_ar_in=false
            else
               ar_1.clear
            end # if
         else
            b_not_ready=false
         end # if
      else # b_take_from_ar_1==false
         i_ar_in_len=ar_2.size
         i_reminder=i_ar_in_len%2
         i_loop=(i_ar_in_len-i_reminder)/2
         i_loop.times do |i|
            i_2=i*2
            s_1=ar_2[i_2]
            s_2=ar_2[i_2+1]
            s_3=s_1+s_2
            ar_1<<s_3
         end # loop
         if i_reminder==1
            s_3=ar_2[i_ar_in_len-1]
            ar_1<<s_3
         end # if
         i_ar_out_len=ar_1.size
         if 1<i_ar_out_len
            ar_2.clear
         else
            b_not_ready=false
         end # if
      end # if
      b_take_from_ar_1=!b_take_from_ar_1
   end # loop
   if i_ar_out_len==1
      if b_take_from_ar_1
         s_out=ar_1[0]
      else
         s_out=ar_2[0]
      end # if
   else
      # The s_out has been inited to "".
      if 0<i_ar_out_len
         raise Exception.new("This function is flawed.")
      end # if
   end # if
   return s_out
end

#kibuvits_krl171bt4_s_exception_2_stacktrace(e) ⇒ Object




644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 644

def kibuvits_krl171bt4_s_exception_2_stacktrace(e)
   if (e.class.kind_of? Exception)
      exc=Exception.new("e.class=="+e.class.to_s+
      ", but Exception or any of its descendents was expected.")
      raise(exc)
   end # if
   ar_stack_trace=e.backtrace.reverse
   s_lc_separ="--------------------"
   s_lc_linebreak="\n"
   s_stacktrace=""+s_lc_separ
   ar_stack_trace.each do |s_line|
      s_stacktrace=s_stacktrace+s_lc_linebreak+s_line
   end # loop
   s_stacktrace=s_stacktrace+s_lc_linebreak+s_lc_separ+s_lc_linebreak
   return s_stacktrace
end

#kibuvits_krl171bt4_s_hash_t1(s_in, i_bitlen = 512) ⇒ Object


i_bitlen in_Set256,384,512



2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 2019

def kibuvits_krl171bt4_s_hash_t1(s_in,i_bitlen=512)
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, String,s_in
      kibuvits_krl171bt4_typecheck bn, [Integer,Fixnum,Bignum],i_bitlen
      ar=[256,384,512]
      kibuvits_krl171bt4_assert_is_among_values(bn,ar,i_bitlen)
   end # if
   if !defined? $kibuvits_krl171bt4_func_s_hash_b_module_digest_loaded
      require "digest"
      $kibuvits_krl171bt4_func_s_hash_b_module_digest_loaded=true
   end # if
   ob_hashfunc=Digest::SHA2.new(i_bitlen)
   s_out=ob_hashfunc.hexdigest(s_in)
   return s_out
end

#kibuvits_krl171bt4_s_varvalue2varname(a_binding, ob_varvalue, ar_an_empty_array_for_reuse_only_for_speed = Array.new) ⇒ Object

Returns an empty string, if the variable could not be found from the scope. The ar_an_empty_array_for_reuse_only_for_speed is guaranteed to be empty after the exit of this function.



828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 828

def kibuvits_krl171bt4_s_varvalue2varname(a_binding, ob_varvalue,
   ar_an_empty_array_for_reuse_only_for_speed=Array.new)
   # The use of the kibuvits_krl171bt4_typecheck in here
   # would introduce a cyclic dependency.
   ar=ar_an_empty_array_for_reuse_only_for_speed
   s_script=$kibuvits_krl171bt4_lc_kibuvits_krl171bt4_s_varvalue2varname_s1+
   ar.object_id.to_s+$kibuvits_krl171bt4_lc_rbrace_linebreak+
   $kibuvits_krl171bt4_lc_kibuvits_krl171bt4_s_varvalue2varname_s2+
   ob_varvalue.object_id.to_s+$kibuvits_krl171bt4_lc_rbrace_linebreak+
   $kibuvits_krl171bt4_lc_kibuvits_krl171bt4_s_varvalue2varname_script1 # instance reuse

   eval(s_script,a_binding)
   # Actually a scope may contain multiple variables
   # that reference the same instance, but due to
   # performance considerations this function here
   # is expected to stop the search right after it
   # has found one of the variables or searched the whole scope.
   i=ar.size
   if 1<i
      ar.clear # due to the possible speed related array reuse
      kibuvits_krl171bt4_throw("1<ar.size=="+i.to_s)
   end # if
   s_varname=nil
   if ar.size==0
      # It's actually legitimate for the instance to
      # miss a variable, designating symbol, within the scope that
      # the a_binding references, because the instance
      # might have been referenced by an object id or by some
      # other way by using reflection or fed in like
      # kibuvits_krl171bt4_s_varvalue2varname(binding(), an_awesome_function())
      s_varname=$kibuvits_krl171bt4_lc_emptystring
   else
      s_varname=ar[0]
      ar.clear
   end # if
   return s_varname
end

#kibuvits_krl171bt4_set_var_in_scope(a_binding, s_varname, x_varvalue, ar_an_empty_array_for_reuse_only_for_speed = Array.new) ⇒ Object

The ar_an_empty_array_for_reuse_only_for_speed is guaranteed to be empty after the exit of this function.



874
875
876
877
878
879
880
881
882
883
884
885
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 874

def kibuvits_krl171bt4_set_var_in_scope(a_binding, s_varname,x_varvalue,
   ar_an_empty_array_for_reuse_only_for_speed=Array.new)
   # The use of the kibuvits_krl171bt4_typecheck in here
   # would introduce a cyclic dependency.
   ar=ar_an_empty_array_for_reuse_only_for_speed
   ar<<x_varvalue
   s_script=$kibuvits_krl171bt4_lc_kibuvits_krl171bt4_set_var_in_scope_s1+
   ar.object_id.to_s+$kibuvits_krl171bt4_lc_rbrace_linebreak+
   s_varname+$kibuvits_krl171bt4_lc_kibuvits_krl171bt4_set_var_in_scope_s2
   eval(s_script,a_binding)
   ar.clear
end

#kibuvits_krl171bt4_sh(s_shell_script) ⇒ Object

Writes a script to a file and executes it in Bash. Returns a hashtable with keys “s_stdout” and “s_stderr”. The values that are pointed by the keys are always strings.

The line breaks within the s_stdout, s_stderr have been normalized to the “n”. In case of Windows the 2 header lines and the footer line have been removed from the s_stdout.



7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 7720

def kibuvits_krl171bt4_sh(s_shell_script)
   if KIBUVITS_krl171bt4_b_DEBUG
      kibuvits_krl171bt4_typecheck binding(), String, s_shell_script
   end # if
   s_ostype=Kibuvits_krl171bt4_os_codelets.instance.get_os_type
   ht_stdstreams=nil
   $kibuvits_krl171bt4_lc_mx_sh.synchronize do
      case s_ostype
      when "kibuvits_krl171bt4_ostype_unixlike"
         ht_stdstreams=kibuvits_krl171bt4_sh_unix(s_shell_script)
      else
         # Some of the cases, where it happens:
         # "kibuvits_krl171bt4_ostype_java", "kibuvits_krl171bt4_ostype_windows"
         kibuvits_krl171bt4_throw("Operating system with the "+
         "Kibuvits Ruby Library operating system type \""+
         s_ostype+"\" is not supported by this function.")
      end # case
   end # synchronize
   return ht_stdstreams
end

#kibuvits_krl171bt4_sh_unix(s_shell_script) ⇒ Object

It’s a sub-function of the function sh



7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 7661

def kibuvits_krl171bt4_sh_unix(s_shell_script)
   if KIBUVITS_krl171bt4_b_DEBUG
      kibuvits_krl171bt4_typecheck binding(), String, s_shell_script
   end # if
   s_fp_script_0=Kibuvits_krl171bt4_os_codelets.instance.generate_tmp_file_absolute_path
   s_fp_stdout=Kibuvits_krl171bt4_os_codelets.instance.generate_tmp_file_absolute_path
   s_fp_stderr=Kibuvits_krl171bt4_os_codelets.instance.generate_tmp_file_absolute_path
   #------------
   b_throw_if_not_found=true
   s_fp_bash=Kibuvits_krl171bt4_shell.s_exc_system_specific_path_by_caching_t1(
   "bash", b_throw_if_not_found)
   #------------
   kibuvits_krl171bt4_str2file(s_shell_script,s_fp_script_0)
   kibuvits_krl171bt4_str2file($kibuvits_krl171bt4_lc_emptystring,s_fp_stdout)
   kibuvits_krl171bt4_str2file($kibuvits_krl171bt4_lc_emptystring,s_fp_stderr)
   cmd=s_fp_bash+$kibuvits_krl171bt4_lc_space+s_fp_script_0+" 1>"+s_fp_stdout+" 2>"+s_fp_stderr+" ;"
   ht_stdstreams=Kibuvits_krl171bt4_io.create_empty_ht_stdstreams
   begin
      # Kernel.system return values:
      #     true  on success, e.g. program returns 0 as execution status
      #     false on successfully started program that
      #              returns nonzero execution status
      #     nil   on command that could not be executed
      x_success=system(cmd)

      # An alternative version that needs improvement:
      #
      #     x_success=nil
      #     IO.popen(cmd) {x_success=true }
      #
   rescue Exception=>e
      File.delete(s_fp_script_0)
      File.delete(s_fp_stdout)
      File.delete(s_fp_stderr)
      kibuvits_krl171bt4_throw e.message.to_s
   end # try-catch
   s_stdout=Kibuvits_krl171bt4_str.normalise_linebreaks(
   kibuvits_krl171bt4_file2str(s_fp_stdout),$kibuvits_krl171bt4_lc_linebreak)
   s_stderr=Kibuvits_krl171bt4_str.normalise_linebreaks(
   kibuvits_krl171bt4_file2str(s_fp_stderr),$kibuvits_krl171bt4_lc_linebreak)
   File.delete(s_fp_script_0) if File.exists? s_fp_script_0
   File.delete(s_fp_stdout) if File.exists? s_fp_stdout
   File.delete(s_fp_stderr) if File.exists? s_fp_stderr
   ht_stdstreams[$kibuvits_krl171bt4_lc_s_stdout]=s_stdout
   ht_stdstreams[$kibuvits_krl171bt4_lc_s_stderr]=s_stderr
   return ht_stdstreams
end

#kibuvits_krl171bt4_sh_writeln2console_t1(s_shell_script) ⇒ Object

The same as the kibuvits_krl171bt4_sh(…), except that it prints the output streams, if there’s any output.



7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 7745

def kibuvits_krl171bt4_sh_writeln2console_t1(s_shell_script)
   ht_stdstreams=sh(s_shell_script)
   s_stdout=ht_stdstreams[$kibuvits_krl171bt4_lc_s_stdout]
   s_stderr=ht_stdstreams[$kibuvits_krl171bt4_lc_s_stderr]
   kibuvits_krl171bt4_writeln s_stdout if 0<s_stdout.length
   if 0<s_stderr.length
      kibuvits_krl171bt4_writeln $kibuvits_krl171bt4_lc_linebreak+s_stderr+$kibuvits_krl171bt4_lc_linebreak
   end # if
   return ht_stdstreams
end

#kibuvits_krl171bt4_str2file(s_a_string, s_fp) ⇒ Object




6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 6692

def kibuvits_krl171bt4_str2file(s_a_string, s_fp)
   if KIBUVITS_krl171bt4_RUBY_LIBRARY_IS_AVAILABLE
      if KIBUVITS_krl171bt4_b_DEBUG
         bn=binding()
         kibuvits_krl171bt4_typecheck bn, String, s_a_string
         kibuvits_krl171bt4_typecheck bn, String, s_fp
      end # if
   end # if
   $kibuvits_krl171bt4_lc_mx_streamaccess.synchronize do
      begin
         file=File.open(s_fp, "w")
         file.write(s_a_string)
         file.close
      rescue Exception =>err
         raise "No comments. GUID='67c87531-011a-4cf6-b59f-c13290a118e7' \n"+
         "s_a_string=="+s_a_string+"\n"+err.to_s+"\n\n"
      end #
   end # synchronize
end

#kibuvits_krl171bt4_str2file_by_dearmour_t1(s_armoured, s_file_path) ⇒ Object

The string must conform to the format of the kibuvits_krl171bt4_s_armour_t1(…)



6934
6935
6936
6937
6938
6939
6940
6941
6942
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 6934

def kibuvits_krl171bt4_str2file_by_dearmour_t1(s_armoured,s_file_path)
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, String, s_armoured
      kibuvits_krl171bt4_typecheck bn, String, s_file_path
   end # if
   ar_i=kibuvits_krl171bt4_ar_i_dearmour_t1(s_armoured)
   kibuvits_krl171bt4_ar_i_2_file_t1(ar_i,s_file_path)
end

#kibuvits_krl171bt4_testeval(a_binding, teststring) ⇒ Object

The .selftest methods depend on this function. This function is located here because the other 2 alternatives are more verbose. First alternative would be to “require” it in every .selftest method, which is redundant and the other alternative would be to “require” it from another file in here, which seems uselessly costly and verbose.



2180
2181
2182
2183
2184
2185
2186
2187
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 2180

def kibuvits_krl171bt4_testeval(a_binding,teststring)
   s_script="begin\n"+
   teststring+"\n"+
   "rescue Exception => e\n"+
   "    ar_msgs<<\""+teststring+": \\n\"+e.to_s\n"+
   "end # rescue\n"
   eval(s_script,a_binding)
end

#kibuvits_krl171bt4_throw(s_or_ob_exception, a_binding = nil) ⇒ Object

The a_binding is an optional parameter of type Binding.

If the a_binding!=nil, then the exception is thrown in the scope that is referenced by the a_binding.

The kibuvits_krl171bt4_throw(…) does not depend on any other parts of the Kibuvits Ruby Library.



668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 668

def kibuvits_krl171bt4_throw(s_or_ob_exception,a_binding=nil)
   # Due to the lack of dependence on other
   # functions the implementation here is quite
   # verbose and duplicating, but that's the
   # compromise where elegant core API is favored
   # over an elegant core API implementation.
   #
   # A reminder: the keywords catch and throw have
   # a nonstandard semantics in Ruby.
   #-------------------------------------------------
   x_in=s_or_ob_exception
   #-------------------------------------------------
   # Typecheck of the s_or_ob_exception
   b_input_verification_failed=false
   s_msg=nil
   # The classes String and Exception both have the to_s method.
   # The input verification should throw within the scope that
   # contains the call to the kibuvits_krl171bt4_throw(...), regardless
   # of the value of the a_binding, because the flaw that caused
   # verification failure resides in the scope, where the
   # call to the kibuvits_krl171bt4_throw(...) was made.
   if !(x_in.respond_to? "to_s")
      b_input_verification_failed=true
      s_msg=" (s_or_ob_exception.respond_to? \"to_s\")==false\n"
   else
      begin
         s_msg=x_in.to_s
      rescue Exception => e
         b_input_verification_failed=true
         s_msg=" s_or_ob_exception.to_s() could not be executed. \n"
      end # rescue
   end # if
   b_raise=false
   if b_input_verification_failed
      s_msg=s_msg+" s_or_ob_exception.class=="+x_in.class.to_s+"\n"
      b_raise=true
   end # if
   if !b_raise
      if x_in.class!=String
         if !(x_in.kind_of? Exception)
            s_msg=" s_or_ob_exception.class=="+x_in.class.to_s+
            ", but it is expected to be of class String or Exception or "+
            "derived from the class Exception.\n"
            b_raise=true
         end # if
      end # if
   end # if
   if !b_raise
      if a_binding.class!=NilClass
         if a_binding.class!=Binding
            s_msg=" a_binding.class=="+a_binding.class.to_s+
            ", but it is expected to be of class NilClass or Binding.\n"
            b_raise=true
         end # if
      end # if
   end # if
   if b_raise
      if KIBUVITS_krl171bt4_b_DEBUG
         if !$kibuvits_krl171bt4_var_b_running_selftests
            s_fp_mmmv_devel_tools_info=ENV["MMMV_DEVEL_TOOLS_HOME"]+
            "/src/api/mmmv_devel_tools_info.bash"
            if File.exists? s_fp_mmmv_devel_tools_info
               s_0=` $MMMV_DEVEL_TOOLS_HOME/src/api/mmmv_devel_tools_info.bash \
               get_config s_GUID_trace_errorstack_file_path `
               s_1=s_0.gsub(/[\n\r]/,$kibuvits_krl171bt4_lc_emptystring)
               if File.exists? s_1
                  # A bit flawed, because sometimes the file has
                  # to be created, for example, after all caches
                  # have been erased, but this if-branch here is
                  # such a hack that one does not risk creating the file.
                  # The next is a crippled, checkless copy-paste from
                  # kibuvits_krl171bt4_io.rb
                  s_fp=s_1
                  file=File.open(s_fp, "w")
                  file.write(s_msg)
                  file.close
               end # if
            end # if
         end # if
      end # if
      raise(Exception.new(s_msg))
   end # if
   #-------------------------------------------------
   exc=nil
   if x_in.class==String
      exc=Exception.new($kibuvits_krl171bt4_lc_doublelinebreak+
      x_in+$kibuvits_krl171bt4_lc_doublelinebreak)
   else # x_in.class is derived from or equal to the Exception.
      exc=x_in
   end # if
   #-------------------------------------
   # The following adds a stack trace to the exception message.
   # ar_stack_trace=exc.backtrace.reverse
   # s_lc_separ="--------------------"
   # s_lc_linebreak="\n"
   # s_msg=exc.to_s+s_lc_linebreak+kibuvits_krl171bt4_s_exception_2_stacktrace(exc)
   # exc=Exception.new(s_msg)
   #-------------------------------------
   raise(exc) if a_binding==nil # stops a recursion.
   #-------------------------------------
   # The start of the "kibuvits_krl171bt4_throw_in_scope".
   ar=[exc]
   s_script=$kibuvits_krl171bt4_lc_kibuvits_krl171bt4_set_var_in_scope_s1+
   ar.object_id.to_s+$kibuvits_krl171bt4_lc_rbrace_linebreak+
   "kibuvits_krl171bt4_throw_x_exc"+$kibuvits_krl171bt4_lc_kibuvits_krl171bt4_set_var_in_scope_s2+
   "kibuvits_krl171bt4_throw(kibuvits_krl171bt4_throw_x_exc)\n"
   eval(s_script,a_binding)
end

#kibuvits_krl171bt4_typecheck(a_binding, expected_class_or_an_array_of_expected_classes, a_variable, s_msg_complement = nil) ⇒ Object

a_binding==Kernel.binding()



891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 891

def kibuvits_krl171bt4_typecheck(a_binding,expected_class_or_an_array_of_expected_classes,
   a_variable,s_msg_complement=nil)
   if KIBUVITS_krl171bt4_b_DEBUG
      if a_binding.class!=Binding
         kibuvits_krl171bt4_throw("\nThe class of the 1. argument of the "+
         "function kibuvits_krl171bt4_typecheck,\n"+
         "the a_binding, is expected to be Binding, but the class of \n"+
         "the received value was "+a_binding.class.to_s+
         ".\na_binding.to_s=="+a_binding.to_s+"\n")
      end # if
      cl=s_msg_complement.class
      if (cl!=String)&&(cl!=NilClass)
         kibuvits_krl171bt4_throw("\nThe class of the 3. argument of the "+
         "function kibuvits_krl171bt4_typecheck,\n"+
         "the s_msg_complement, is expected to be either String or NilClass,\n"+
         "but the class of the received value was "+cl.to_s+
         ".\ns_msg_complement.to_s=="+s_msg_complement.to_s+"\n")
      end # if
   end # if
   xcorar=expected_class_or_an_array_of_expected_classes
   b_failure=true
   if xcorar.class==Class
      b_failure=(a_variable.class!=xcorar)
   else
      if xcorar.class==Array
         xcorar.each do |an_expected_class|
            if a_variable.class==an_expected_class
               b_failure=false
               break
            end # if
         end # loop
      else
         kibuvits_krl171bt4_throw("\nThe class of the 2. argument of the "+
         "function kibuvits_krl171bt4_typecheck,\n"+
         "the expected_class_or_an_array_of_expected_classes,\n"+
         "is expected to be either Class or Array, but the class of \n"+
         "the received value was "+xcorar.class.to_s+
         ".\nexpected_class_or_an_array_of_expected_classes.to_s=="+
         expected_class_or_an_array_of_expected_classes.to_s+"\n")
      end # if
   end # if
   if b_failure
      # Speed-optimizing exception throwing speeds up selftests,
      # i.e. I'm not that big of a moron as it might seem at first glance. :-D
      ar_tmp_for_speed=Array.new
      # It's actually legitimate for the value of the a_variable to
      # miss a variable, designating symbol, within the scope that
      # the a_binding references, because the value of the a_variable
      # might have been referenced by an object id or by some
      # other way by using reflection or fed in here like
      # kibuvits_krl171bt4_typecheck(binding(),NiceClass, an_awesome_function())
      s_varname=kibuvits_krl171bt4_s_varvalue2varname(a_binding,
      a_variable,ar_tmp_for_speed)
      s=nil
      if 0<s_varname.length
         s="\n"+s_varname+".class=="+a_variable.class.to_s+
         ", but the "+s_varname+" is expected \nto be of "
      else
         s="\nFound class "+a_variable.class.to_s+", but expected "
      end # if
      if xcorar.class==Class
         s=s+"class "+ xcorar.to_s+".\n"
      else
         s_cls="one of the following classes:\n"
         b_comma_needed=false
         xcorar.each do |an_expected_class|
            s_cls=s_cls+", " if b_comma_needed
            b_comma_needed=true
            s_cls=s_cls+an_expected_class.to_s
         end # loop
         s=s+s_cls+".\n"
      end # if
      s=s+s_msg_complement+"\n" if s_msg_complement.class==String
      kibuvits_krl171bt4_set_var_in_scope(a_binding,
      "kibuvits_krl171bt4_typecheck_s_msg",s,ar_tmp_for_speed)
      eval("kibuvits_krl171bt4_throw(kibuvits_krl171bt4_typecheck_s_msg)\n",a_binding)
   end # if
   return b_failure
end

#kibuvits_krl171bt4_typecheck_ar_content(a_binding, expected_class_or_an_array_of_expected_classes, ar_verifiable_values, s_msg_complement = nil) ⇒ Object

kibuvits_krl171bt4_typecheck



971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 971

def kibuvits_krl171bt4_typecheck_ar_content(a_binding,expected_class_or_an_array_of_expected_classes,
   ar_verifiable_values,s_msg_complement=nil)
   bn=binding()
   if KIBUVITS_krl171bt4_b_DEBUG
      kibuvits_krl171bt4_typecheck bn, Binding, a_binding
      kibuvits_krl171bt4_typecheck bn, [Class,Array], expected_class_or_an_array_of_expected_classes
      kibuvits_krl171bt4_typecheck bn, Array, ar_verifiable_values
      kibuvits_krl171bt4_typecheck bn, [NilClass,String], s_msg_complement
      if expected_class_or_an_array_of_expected_classes.class==Array
         expected_class_or_an_array_of_expected_classes.each do |cl_candidate|
            bn_1=binding()
            kibuvits_krl171bt4_typecheck bn_1, Class, cl_candidate
         end # loop
      end # if
   end # if
   ar_cl=expected_class_or_an_array_of_expected_classes
   if expected_class_or_an_array_of_expected_classes.class==Class
      ar_cl=[expected_class_or_an_array_of_expected_classes]
   end # if
   b_throw=false
   x_value=nil
   ar_verifiable_values.each do |x_verifiable|
      b_throw=true
      x_value=x_verifiable
      ar_cl.each do |cl_allowed|
         if x_verifiable.class==cl_allowed
            b_throw=false
            break
         end # if
      end # loop
      break if b_throw
   end # loop
   if b_throw
      kibuvits_krl171bt4_typecheck(a_binding,expected_class_or_an_array_of_expected_classes,
      x_value,s_msg_complement)
   end # if
   b_failure=b_throw
   return b_failure
end

#kibuvits_krl171bt4_varname2varvalue(a_binding, s_varname, ar_an_empty_array_for_reuse_only_for_speed = Array.new) ⇒ Object

Returns the value that the variable :s_varname has within the scope that is being referenced by the a_binding. The ar_an_empty_array_for_reuse_only_for_speed is guaranteed to be empty after this function exits.



787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 787

def kibuvits_krl171bt4_varname2varvalue(a_binding, s_varname,
   ar_an_empty_array_for_reuse_only_for_speed=Array.new)
   # The use of the kibuvits_krl171bt4_typecheck in here
   # would introduce a cyclic dependency.
   ar=ar_an_empty_array_for_reuse_only_for_speed
   s_script=$kibuvits_krl171bt4_lc_kibuvits_krl171bt4_varname2varvalue_s1+
   ar.object_id.to_s+$kibuvits_krl171bt4_lc_kibuvits_krl171bt4_varname2varvalue_s2+
   s_varname+$kibuvits_krl171bt4_lc_linebreak
   eval(s_script,a_binding)
   kibuvits_krl171bt4_throw("ar.size==0") if ar.size==0
   x=ar[0]
   # even the kibuvits_krl171bt4_s_varvalue2varname depends on the emptiness of the ar
   ar.clear
   return x
end

#kibuvits_krl171bt4_write(x_in) ⇒ Object




622
623
624
625
626
627
628
629
630
631
632
633
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 622

def kibuvits_krl171bt4_write(x_in)
   $kibuvits_krl171bt4_lc_mx_streamaccess.synchronize do
      # The "" is just for reducing the probability of
      # mysterious memory sharing related quirk-effects.
      #--------------
      # The classical version
      print $kibuvits_krl171bt4_lc_emptystring+x_in.to_s
      #--------------
      # A more explicit version
      #$stdout.write(sprintf("s", x_in))
   end # synchronize
end

#kibuvits_krl171bt4_write_to_stdout(data) ⇒ Object

For string output, the kibuvits_krl171bt4_writeln and kibuvits_krl171bt4_write are defined in the kibuvits_krl171bt4_boot.rb WARNING: it’s not that well tested.



6681
6682
6683
6684
6685
6686
6687
6688
6689
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 6681

def kibuvits_krl171bt4_write_to_stdout data
   $kibuvits_krl171bt4_lc_mx_streamaccess.synchronize do
      # It's like the kibuvits_krl171bt4_writeln, but without the
      an_io=STDOUT.reopen($stdout)
      an_io.write data
      an_io.flush
      an_io.close
   end # synchronize
end

#kibuvits_krl171bt4_writeln(x_in) ⇒ Object

kibuvits_krl171bt4_write



634
635
636
637
638
639
640
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 634

def kibuvits_krl171bt4_writeln(x_in)
   $kibuvits_krl171bt4_lc_mx_streamaccess.synchronize do
      # The "" is just for reducing the probability of
      # mysterious memory sharing related quirk-effects.
      puts $kibuvits_krl171bt4_lc_emptystring+x_in.to_s
   end # synchronize
end

#read_a_line_from_consoleObject

The main purpose of this method is to encapsulate the console reading code, because there’s just too many unanswered questions about the console reading.



6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 6949

def read_a_line_from_console
   s_out=nil
   $kibuvits_krl171bt4_lc_mx_streamaccess.synchronize do
      # The IO.gets() treats console arguments as if they would have
      # been  as user input for a query. For some weird reason,
      # the current solution works.
      s_out=""+$stdin.gets
   end # synchronize
   return s_out
end

#write_2_console(a_string) ⇒ Object

read_a_line_from_console



6960
6961
6962
6963
6964
6965
6966
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 6960

def write_2_console a_string
   $kibuvits_krl171bt4_lc_mx_streamaccess.synchronize do
      # The "" is just for reducing the probability of
      # mysterious memory sharing related quirk-effects.
      $stdout.write ""+a_string.to_s
   end # synchronize
end

#writeln_2_console(a_string, i_number_of_prefixing_linebreaks = 0, i_number_of_suffixing_linebreaks = 1) ⇒ Object

write_2_console



6968
6969
6970
6971
6972
6973
6974
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 6968

def writeln_2_console a_string,
   i_number_of_prefixing_linebreaks=0,
   i_number_of_suffixing_linebreaks=1
   s=("\n"*i_number_of_prefixing_linebreaks)+a_string.to_s+
   ("\n"*i_number_of_suffixing_linebreaks)
   write_2_console s
end