tbpgr_utils 0.0.99 → 0.0.100
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -116,6 +116,7 @@ Or install it yourself as:
|
|
116
116
|
|[TbpgrUtils Object#unless_guard](#objectunless_guard) |data type check for unless_guard |
|
117
117
|
|[SimpleTournament](#simpletournament) |simple tournament |
|
118
118
|
|[TbpgrUtils String#ascii1_other2_size](#stringascii1_other2_size) |count string size. ascii => count1, not ascii => count2 |
|
119
|
+
|[TbpgrUtils String#ascii_unicode_html_table](#stringascii_unicode_html_table) |get ascii_unicode_html_table |
|
119
120
|
|[TbpgrUtils String#ascii_unicode_table](#stringascii_unicode_table) |get ascii_unicode_table |
|
120
121
|
|[TbpgrUtils String#comma_to_a](#stringcomma_to_a) |comma-format string to array |
|
121
122
|
|[TbpgrUtils String#escape_quote](#stringescape_quote) |escape quote |
|
@@ -145,7 +146,7 @@ require 'tbpgr_utils'
|
|
145
146
|
[['header1', 'header2', 'header3'],['line1_1', 'line1_2', 'line1_3']].to_table
|
146
147
|
~~~
|
147
148
|
|
148
|
-
result
|
149
|
+
result
|
149
150
|
~~~
|
150
151
|
|header1|header2|header3|
|
151
152
|
|line1_1|line1_2|line1_3|
|
@@ -158,7 +159,7 @@ result
|
|
158
159
|
[['header1', 'header2', 'header3'],['line1_1', 'line1_2', 'line1_3']].to_html_table
|
159
160
|
~~~
|
160
161
|
|
161
|
-
result
|
162
|
+
result
|
162
163
|
~~~
|
163
164
|
<table>
|
164
165
|
<tr>
|
@@ -179,7 +180,7 @@ no header case
|
|
179
180
|
[['not_header1', 'not_header2', 'not_header3'],['line1_1', 'line1_2', 'line1_3']].to_html_table({no_header: true})
|
180
181
|
~~~
|
181
182
|
|
182
|
-
result
|
183
|
+
result
|
183
184
|
~~~
|
184
185
|
<table>
|
185
186
|
<tr>
|
@@ -292,7 +293,7 @@ ret = lists.together_delete 2
|
|
292
293
|
print lists # => output [[1, 3, 4], [3, 4, 5]]
|
293
294
|
~~~
|
294
295
|
|
295
|
-
if delete target is not exist
|
296
|
+
if delete target is not exist
|
296
297
|
~~~ruby
|
297
298
|
require 'tbpgr_utils'
|
298
299
|
|
@@ -304,7 +305,7 @@ print ret # => nil
|
|
304
305
|
print lists # => output [[1, 2, 3, 4], [2, 3, 4, 5]]
|
305
306
|
~~~
|
306
307
|
|
307
|
-
if delete target is not exist and use block
|
308
|
+
if delete target is not exist and use block
|
308
309
|
~~~ruby
|
309
310
|
require 'tbpgr_utils'
|
310
311
|
|
@@ -319,7 +320,7 @@ print lists # => output [[1, 2, 3, 4], [2, 3, 4, 5]]
|
|
319
320
|
[back to list](#list)
|
320
321
|
|
321
322
|
### Array#together_delete_at
|
322
|
-
if delete_at target is exist
|
323
|
+
if delete_at target is exist
|
323
324
|
~~~ruby
|
324
325
|
require 'tbpgr_utils'
|
325
326
|
|
@@ -331,7 +332,7 @@ print ret # => [3, 4]
|
|
331
332
|
print lists # => output [[1, 2, 4], [2, 3, 5]]
|
332
333
|
~~~
|
333
334
|
|
334
|
-
if delete_at target is not exist
|
335
|
+
if delete_at target is not exist
|
335
336
|
~~~ruby
|
336
337
|
require 'tbpgr_utils'
|
337
338
|
|
@@ -343,7 +344,7 @@ print ret # => [nil, nil]
|
|
343
344
|
print lists # => output [[1, 2, 3, 4], [2, 3, 4, 5]]
|
344
345
|
~~~
|
345
346
|
|
346
|
-
if delete_at target is exist(minus index)
|
347
|
+
if delete_at target is exist(minus index)
|
347
348
|
~~~ruby
|
348
349
|
require 'tbpgr_utils'
|
349
350
|
|
@@ -358,7 +359,7 @@ print lists # => output [[1, 3, 4], [2, 4, 5]]
|
|
358
359
|
[back to list](#list)
|
359
360
|
|
360
361
|
### Array#together_delete_if
|
361
|
-
if delete_if target is exist
|
362
|
+
if delete_if target is exist
|
362
363
|
~~~ruby
|
363
364
|
require 'tbpgr_utils'
|
364
365
|
|
@@ -367,7 +368,7 @@ ret = lists.together_delete_if {|first, second|(first + second).odd?}
|
|
367
368
|
print ret # => [[2, 4], [4, 8]]
|
368
369
|
~~~
|
369
370
|
|
370
|
-
if delete_if target is not exist. return nil.
|
371
|
+
if delete_if target is not exist. return nil.
|
371
372
|
~~~ruby
|
372
373
|
require 'tbpgr_utils'
|
373
374
|
|
@@ -379,7 +380,7 @@ print ret # => nil
|
|
379
380
|
[back to list](#list)
|
380
381
|
|
381
382
|
### Array#together_empty?
|
382
|
-
empty case
|
383
|
+
empty case
|
383
384
|
~~~ruby
|
384
385
|
require 'tbpgr_utils'
|
385
386
|
|
@@ -388,7 +389,7 @@ ret = lists.together_empty?
|
|
388
389
|
print ret # => true
|
389
390
|
~~~
|
390
391
|
|
391
|
-
not empty case
|
392
|
+
not empty case
|
392
393
|
~~~ruby
|
393
394
|
require 'tbpgr_utils'
|
394
395
|
|
@@ -400,7 +401,7 @@ print ret # => false
|
|
400
401
|
[back to list](#list)
|
401
402
|
|
402
403
|
### Array#together_fill
|
403
|
-
not use block case
|
404
|
+
not use block case
|
404
405
|
~~~ruby
|
405
406
|
require 'tbpgr_utils'
|
406
407
|
|
@@ -409,7 +410,7 @@ ret = lists.together_fill(99)
|
|
409
410
|
print ret # => [[99, 99, 99, 99, 99], [99, 99, 99, 99, 99]]
|
410
411
|
~~~
|
411
412
|
|
412
|
-
use block, no args case
|
413
|
+
use block, no args case
|
413
414
|
~~~ruby
|
414
415
|
require 'tbpgr_utils'
|
415
416
|
|
@@ -418,7 +419,7 @@ ret = lists.together_fill { |i|(i + 1) + 1 }
|
|
418
419
|
print ret # => [[2, 3, 4, 5, 6], [2, 3, 4, 5, 6]]
|
419
420
|
~~~
|
420
421
|
|
421
|
-
use block, has args case
|
422
|
+
use block, has args case
|
422
423
|
~~~ruby
|
423
424
|
require 'tbpgr_utils'
|
424
425
|
|
@@ -430,7 +431,7 @@ print ret # => [[1, 2, 4, 5, 6], [6, 7, 4, 5, 6]]
|
|
430
431
|
[back to list](#list)
|
431
432
|
|
432
433
|
### Array#together_first
|
433
|
-
no args case
|
434
|
+
no args case
|
434
435
|
~~~ruby
|
435
436
|
require 'tbpgr_utils'
|
436
437
|
|
@@ -439,7 +440,7 @@ ret = lists.together_first
|
|
439
440
|
print ret # => [1, 6]
|
440
441
|
~~~
|
441
442
|
|
442
|
-
has args 2 case
|
443
|
+
has args 2 case
|
443
444
|
~~~ruby
|
444
445
|
require 'tbpgr_utils'
|
445
446
|
|
@@ -448,7 +449,7 @@ ret = lists.together_first 2
|
|
448
449
|
print ret # => [[1, 2], [6, 7]]
|
449
450
|
~~~
|
450
451
|
|
451
|
-
has args 0 case
|
452
|
+
has args 0 case
|
452
453
|
~~~ruby
|
453
454
|
require 'tbpgr_utils'
|
454
455
|
|
@@ -457,7 +458,7 @@ ret = lists.together_first 0
|
|
457
458
|
print ret # => [[], []]
|
458
459
|
~~~
|
459
460
|
|
460
|
-
has args over size case
|
461
|
+
has args over size case
|
461
462
|
~~~ruby
|
462
463
|
require 'tbpgr_utils'
|
463
464
|
|
@@ -473,7 +474,7 @@ together_include? is bulk version of Array#include?
|
|
473
474
|
|
474
475
|
together_include? has alias :tinclude?
|
475
476
|
|
476
|
-
both include single ret case
|
477
|
+
both include single ret case
|
477
478
|
~~~ruby
|
478
479
|
require 'tbpgr_utils'
|
479
480
|
|
@@ -482,7 +483,7 @@ ret = lists.together_include? 5
|
|
482
483
|
print ret # => true
|
483
484
|
~~~
|
484
485
|
|
485
|
-
one include single ret case
|
486
|
+
one include single ret case
|
486
487
|
~~~ruby
|
487
488
|
require 'tbpgr_utils'
|
488
489
|
|
@@ -491,7 +492,7 @@ ret = lists.together_include? 9
|
|
491
492
|
print ret # => true
|
492
493
|
~~~
|
493
494
|
|
494
|
-
both not include single ret case
|
495
|
+
both not include single ret case
|
495
496
|
~~~ruby
|
496
497
|
require 'tbpgr_utils'
|
497
498
|
|
@@ -500,7 +501,7 @@ ret = lists.together_include? 10
|
|
500
501
|
print ret # => false
|
501
502
|
~~~
|
502
503
|
|
503
|
-
both include multi ret case
|
504
|
+
both include multi ret case
|
504
505
|
~~~ruby
|
505
506
|
require 'tbpgr_utils'
|
506
507
|
|
@@ -509,7 +510,7 @@ ret = lists.together_include? 5, true
|
|
509
510
|
print ret # => [true, true]
|
510
511
|
~~~
|
511
512
|
|
512
|
-
one include multi ret case
|
513
|
+
one include multi ret case
|
513
514
|
~~~ruby
|
514
515
|
require 'tbpgr_utils'
|
515
516
|
|
@@ -518,7 +519,7 @@ ret = lists.together_include? 9, true
|
|
518
519
|
print ret # => [false, true]
|
519
520
|
~~~
|
520
521
|
|
521
|
-
both not include multi ret case
|
522
|
+
both not include multi ret case
|
522
523
|
~~~ruby
|
523
524
|
require 'tbpgr_utils'
|
524
525
|
|
@@ -532,7 +533,7 @@ print ret # => [false, false]
|
|
532
533
|
### Array#together_index
|
533
534
|
together_index has alias :tindex
|
534
535
|
|
535
|
-
both index exist case
|
536
|
+
both index exist case
|
536
537
|
~~~ruby
|
537
538
|
require 'tbpgr_utils'
|
538
539
|
|
@@ -541,7 +542,7 @@ ret = lists.together_index 5
|
|
541
542
|
print ret # => [4, 0]
|
542
543
|
~~~
|
543
544
|
|
544
|
-
one include single ret case
|
545
|
+
one include single ret case
|
545
546
|
~~~ruby
|
546
547
|
require 'tbpgr_utils'
|
547
548
|
|
@@ -550,7 +551,7 @@ ret = lists.together_index 4
|
|
550
551
|
print ret # => [3, nil]
|
551
552
|
~~~
|
552
553
|
|
553
|
-
both not include single ret case
|
554
|
+
both not include single ret case
|
554
555
|
~~~ruby
|
555
556
|
require 'tbpgr_utils'
|
556
557
|
|
@@ -564,7 +565,7 @@ print ret # => [nil, nil]
|
|
564
565
|
### Array#together_insert
|
565
566
|
together_insert has alias :tinsert
|
566
567
|
|
567
|
-
both insert exist case
|
568
|
+
both insert exist case
|
568
569
|
~~~ruby
|
569
570
|
require 'tbpgr_utils'
|
570
571
|
|
@@ -573,7 +574,7 @@ ret = lists.together_insert(1, 55, 66)
|
|
573
574
|
print ret # => [[1, 55, 66, 2, 3, 4, 5], [5, 55, 66, 6, 7, 8, 9]]
|
574
575
|
~~~
|
575
576
|
|
576
|
-
both insert exist and minus index case
|
577
|
+
both insert exist and minus index case
|
577
578
|
~~~ruby
|
578
579
|
require 'tbpgr_utils'
|
579
580
|
|
@@ -582,7 +583,7 @@ ret = lists.together_insert(-2, 55, 66)
|
|
582
583
|
print ret # => [[1, 2, 3, 4, 55, 66, 5], [5, 6, 7, 8, 55, 66, 9]]
|
583
584
|
~~~
|
584
585
|
|
585
|
-
both insert exist case
|
586
|
+
both insert exist case
|
586
587
|
~~~ruby
|
587
588
|
require 'tbpgr_utils'
|
588
589
|
|
@@ -596,7 +597,7 @@ print ret # => [[1, 2, 3, 4, 5, nil, 55, 66], [5, 6, 7, 8, 9, nil, 55, 66]],
|
|
596
597
|
### Array#together_last
|
597
598
|
together_last has alias :tlast
|
598
599
|
|
599
|
-
no args case
|
600
|
+
no args case
|
600
601
|
~~~ruby
|
601
602
|
require 'tbpgr_utils'
|
602
603
|
|
@@ -605,7 +606,7 @@ ret = lists.together_last
|
|
605
606
|
print ret # => [5, 10]
|
606
607
|
~~~
|
607
608
|
|
608
|
-
has args 2 case
|
609
|
+
has args 2 case
|
609
610
|
~~~ruby
|
610
611
|
require 'tbpgr_utils'
|
611
612
|
|
@@ -614,7 +615,7 @@ ret = lists.together_last 2
|
|
614
615
|
print ret # => [[4, 5], [9, 10]]
|
615
616
|
~~~
|
616
617
|
|
617
|
-
has args 0 case
|
618
|
+
has args 0 case
|
618
619
|
~~~ruby
|
619
620
|
require 'tbpgr_utils'
|
620
621
|
|
@@ -623,7 +624,7 @@ ret = lists.together_last 0
|
|
623
624
|
print ret # => [[], []]
|
624
625
|
~~~
|
625
626
|
|
626
|
-
has args over size case
|
627
|
+
has args over size case
|
627
628
|
~~~ruby
|
628
629
|
require 'tbpgr_utils'
|
629
630
|
|
@@ -644,7 +645,7 @@ ret = [alpha, numbers].together_map {|first, second|"#{first}:#{second}"}
|
|
644
645
|
print ret # => output [one:1, two:2, three:3]
|
645
646
|
~~~
|
646
647
|
|
647
|
-
if you want to return multi array, following.
|
648
|
+
if you want to return multi array, following.
|
648
649
|
~~~ruby
|
649
650
|
require 'tbpgr_utils'
|
650
651
|
|
@@ -657,7 +658,7 @@ print ret # => output [["one:ret", "two:ret", "three:ret"],["1:ret", "2:ret", "3
|
|
657
658
|
[back to list](#list)
|
658
659
|
|
659
660
|
### Array#together_map!(or tmap!, together_collect!, tcollect!)
|
660
|
-
if you want to return single array, following.
|
661
|
+
if you want to return single array, following.
|
661
662
|
~~~ruby
|
662
663
|
require 'tbpgr_utils'
|
663
664
|
|
@@ -671,7 +672,7 @@ print ret # => output ['one:1', 'two:2', 'three:3']
|
|
671
672
|
print ary # => output ['one:1', 'two:2', 'three:3']
|
672
673
|
~~~
|
673
674
|
|
674
|
-
if you want to return multi array, following.
|
675
|
+
if you want to return multi array, following.
|
675
676
|
~~~ruby
|
676
677
|
require 'tbpgr_utils'
|
677
678
|
|
@@ -690,7 +691,7 @@ print ary # => output [['1:one', '2:two', '3:three'], ['one:1', 'two:2', 'three:
|
|
690
691
|
### Array#together_pop(or tpop)
|
691
692
|
together_pop has alias :tpop
|
692
693
|
|
693
|
-
not empty case
|
694
|
+
not empty case
|
694
695
|
~~~ruby
|
695
696
|
require 'tbpgr_utils'
|
696
697
|
|
@@ -700,7 +701,7 @@ print ret # => [2, 6]
|
|
700
701
|
print lists # => [1, 5]
|
701
702
|
~~~
|
702
703
|
|
703
|
-
empty case
|
704
|
+
empty case
|
704
705
|
~~~ruby
|
705
706
|
require 'tbpgr_utils'
|
706
707
|
|
@@ -710,7 +711,7 @@ print ret # => [nil, nil]
|
|
710
711
|
print lists # => [[], []]
|
711
712
|
~~~
|
712
713
|
|
713
|
-
not empty case with args
|
714
|
+
not empty case with args
|
714
715
|
~~~ruby
|
715
716
|
require 'tbpgr_utils'
|
716
717
|
|
@@ -720,7 +721,7 @@ print ret # => [[1, 2], [5, 6]]
|
|
720
721
|
print lists # => [[], []]
|
721
722
|
~~~
|
722
723
|
|
723
|
-
not empty case with args
|
724
|
+
not empty case with args
|
724
725
|
~~~ruby
|
725
726
|
require 'tbpgr_utils'
|
726
727
|
|
@@ -793,7 +794,7 @@ print ret # => output {1=>4, 2=>2, 3=>3, 4=>1}
|
|
793
794
|
### Array#together_reverse(or :treverse)
|
794
795
|
together_reverse has alias :treverse
|
795
796
|
|
796
|
-
not empty case
|
797
|
+
not empty case
|
797
798
|
~~~ruby
|
798
799
|
require 'tbpgr_utils'
|
799
800
|
|
@@ -803,7 +804,7 @@ print ret # => [[2, 1], [6, 5]]
|
|
803
804
|
print lists # => [[1, 2], [5, 6]]
|
804
805
|
~~~
|
805
806
|
|
806
|
-
one empty case
|
807
|
+
one empty case
|
807
808
|
~~~ruby
|
808
809
|
require 'tbpgr_utils'
|
809
810
|
|
@@ -818,7 +819,7 @@ print lists # => [[1, 2], []]
|
|
818
819
|
### Array#together_reverse!(or :treverse!)
|
819
820
|
together_reverse! has alias :treverse!
|
820
821
|
|
821
|
-
not empty case
|
822
|
+
not empty case
|
822
823
|
~~~ruby
|
823
824
|
require 'tbpgr_utils'
|
824
825
|
|
@@ -828,7 +829,7 @@ print ret # => [[2, 1], [6, 5]]
|
|
828
829
|
print lists # => [[2, 1], [6, 5]]
|
829
830
|
~~~
|
830
831
|
|
831
|
-
one empty case
|
832
|
+
one empty case
|
832
833
|
~~~ruby
|
833
834
|
require 'tbpgr_utils'
|
834
835
|
|
@@ -843,7 +844,7 @@ print lists # => [[2, 1], []]
|
|
843
844
|
### Array#together_sample(or :tsample)
|
844
845
|
together_sample has alias :tsample
|
845
846
|
|
846
|
-
not empty case
|
847
|
+
not empty case
|
847
848
|
~~~ruby
|
848
849
|
require 'tbpgr_utils'
|
849
850
|
|
@@ -852,7 +853,7 @@ ret = lists.together_sample
|
|
852
853
|
print ret # => [1 or 2, 5 or 6]
|
853
854
|
~~~
|
854
855
|
|
855
|
-
empty case
|
856
|
+
empty case
|
856
857
|
~~~ruby
|
857
858
|
require 'tbpgr_utils'
|
858
859
|
|
@@ -861,7 +862,7 @@ ret = lists.together_sample
|
|
861
862
|
print ret # => [nil, nil]
|
862
863
|
~~~
|
863
864
|
|
864
|
-
not empty case with args
|
865
|
+
not empty case with args
|
865
866
|
~~~ruby
|
866
867
|
require 'tbpgr_utils'
|
867
868
|
|
@@ -870,7 +871,7 @@ ret = lists.together_sample 2
|
|
870
871
|
print ret # => [[1 or 2, 1 or 2], [5 or 6, 5 or 6]]
|
871
872
|
~~~
|
872
873
|
|
873
|
-
not empty case with args
|
874
|
+
not empty case with args
|
874
875
|
~~~ruby
|
875
876
|
require 'tbpgr_utils'
|
876
877
|
|
@@ -879,7 +880,7 @@ ret = lists.together_sample 2
|
|
879
880
|
print ret # => [[], []]
|
880
881
|
~~~
|
881
882
|
|
882
|
-
not empty, over size case with args
|
883
|
+
not empty, over size case with args
|
883
884
|
~~~ruby
|
884
885
|
require 'tbpgr_utils'
|
885
886
|
|
@@ -900,7 +901,7 @@ ret = [firsts, seconds].together_select{|first, second|first == second}
|
|
900
901
|
print ret # => output [[2, 3], [2, 3]]
|
901
902
|
~~~
|
902
903
|
|
903
|
-
if you want to return multi array, following.
|
904
|
+
if you want to return multi array, following.
|
904
905
|
~~~ruby
|
905
906
|
require 'tbpgr_utils'
|
906
907
|
|
@@ -915,7 +916,7 @@ print ret # => output [[1, 3], [4, 2]]
|
|
915
916
|
### Array#together_shift(or tshift)
|
916
917
|
together_shift has alias :tshift
|
917
918
|
|
918
|
-
not empty case
|
919
|
+
not empty case
|
919
920
|
~~~ruby
|
920
921
|
require 'tbpgr_utils'
|
921
922
|
|
@@ -925,7 +926,7 @@ print ret # => [1, 5]
|
|
925
926
|
print lists # => [2, 6]
|
926
927
|
~~~
|
927
928
|
|
928
|
-
empty case
|
929
|
+
empty case
|
929
930
|
~~~ruby
|
930
931
|
require 'tbpgr_utils'
|
931
932
|
|
@@ -935,7 +936,7 @@ print ret # => [nil, nil]
|
|
935
936
|
print lists # => [[], []]
|
936
937
|
~~~
|
937
938
|
|
938
|
-
not empty case
|
939
|
+
not empty case
|
939
940
|
~~~ruby
|
940
941
|
require 'tbpgr_utils'
|
941
942
|
|
@@ -945,7 +946,7 @@ print ret # => [[1, 2], [5, 6]]
|
|
945
946
|
print lists # => [[], []]
|
946
947
|
~~~
|
947
948
|
|
948
|
-
not empty case
|
949
|
+
not empty case
|
949
950
|
~~~ruby
|
950
951
|
require 'tbpgr_utils'
|
951
952
|
|
@@ -971,7 +972,7 @@ print ret # => [[1 or 2, 1 or 2], [5 or 6, 5 or 6]]
|
|
971
972
|
[back to list](#list)
|
972
973
|
|
973
974
|
### Array#together_slice(or :tslice)
|
974
|
-
single args case
|
975
|
+
single args case
|
975
976
|
~~~ruby
|
976
977
|
require 'tbpgr_utils'
|
977
978
|
|
@@ -980,7 +981,7 @@ ret = lists.together_slice 2
|
|
980
981
|
print ret # => [3, 8]
|
981
982
|
~~~
|
982
983
|
|
983
|
-
multi args case
|
984
|
+
multi args case
|
984
985
|
~~~ruby
|
985
986
|
require 'tbpgr_utils'
|
986
987
|
|
@@ -989,7 +990,7 @@ ret = lists.together_slice 2, 2
|
|
989
990
|
print ret # => [[3, 4], [8, 9]]
|
990
991
|
~~~
|
991
992
|
|
992
|
-
range args case
|
993
|
+
range args case
|
993
994
|
~~~ruby
|
994
995
|
require 'tbpgr_utils'
|
995
996
|
|
@@ -1058,7 +1059,7 @@ p atr_sample2.atr1 # => atr1
|
|
1058
1059
|
p atr_sample2.atr2 # => atr2
|
1059
1060
|
~~~
|
1060
1061
|
|
1061
|
-
same mean code is
|
1062
|
+
same mean code is
|
1062
1063
|
~~~ruby
|
1063
1064
|
class AccessorSample
|
1064
1065
|
attr_accessor :atr1, :atr2
|
@@ -1104,7 +1105,7 @@ p atr_sample1.atr2 # => atr2
|
|
1104
1105
|
# end
|
1105
1106
|
~~~
|
1106
1107
|
|
1107
|
-
same mean code is
|
1108
|
+
same mean code is
|
1108
1109
|
~~~ruby
|
1109
1110
|
class AccessorSample
|
1110
1111
|
attr_reader :atr1, :atr2
|
@@ -1157,7 +1158,7 @@ atr_sample2.instance_variable_get "@atr1" # => atr1
|
|
1157
1158
|
atr_sample2.instance_variable_get "@atr2" # => atr2
|
1158
1159
|
~~~
|
1159
1160
|
|
1160
|
-
same mean code is
|
1161
|
+
same mean code is
|
1161
1162
|
~~~ruby
|
1162
1163
|
class AccessorSample
|
1163
1164
|
attr_writer :atr1, :atr2
|
@@ -1248,14 +1249,14 @@ Create model that has two fileds that are 'id' and 'parent_ids'.
|
|
1248
1249
|
### File.insert_bom
|
1249
1250
|
* this method's main purpose is 'UTF-8 Excel CSV File'.
|
1250
1251
|
|
1251
|
-
output bommed text from input.csv to output.csv
|
1252
|
+
output bommed text from input.csv to output.csv
|
1252
1253
|
~~~ruby
|
1253
1254
|
require 'tbpgr_utils'
|
1254
1255
|
|
1255
1256
|
File.insert_bom("input.csv", "output.csv") # => output bommed text to output.csv
|
1256
1257
|
~~~
|
1257
1258
|
|
1258
|
-
output bommed text from input.csv to input.csv
|
1259
|
+
output bommed text from input.csv to input.csv
|
1259
1260
|
~~~ruby
|
1260
1261
|
require 'tbpgr_utils'
|
1261
1262
|
|
@@ -1265,13 +1266,13 @@ File.insert_bom("input.csv") # => output bommed text to output.csv
|
|
1265
1266
|
[back to list](#list)
|
1266
1267
|
|
1267
1268
|
### Fixnum.to_fixnum_html_table
|
1268
|
-
1 to 10 by 2 case
|
1269
|
+
1 to 10 by 2 case
|
1269
1270
|
~~~ruby
|
1270
1271
|
require 'tbpgr_utils'
|
1271
1272
|
Fixnum.to_fixnum_html_table(1, 10, 2)
|
1272
1273
|
~~~
|
1273
1274
|
|
1274
|
-
result
|
1275
|
+
result
|
1275
1276
|
~~~
|
1276
1277
|
<table>
|
1277
1278
|
<tr>
|
@@ -1300,12 +1301,12 @@ result
|
|
1300
1301
|
[back to list](#list)
|
1301
1302
|
|
1302
1303
|
### Fixnum.to_fixnum_table
|
1303
|
-
1 to 100 by 10 case
|
1304
|
+
1 to 100 by 10 case
|
1304
1305
|
~~~ruby
|
1305
1306
|
Fixnum.to_fixnum_table(1, 100, 10)
|
1306
1307
|
~~~
|
1307
1308
|
|
1308
|
-
result
|
1309
|
+
result
|
1309
1310
|
~~~
|
1310
1311
|
| 1| 2| 3| 4| 5| 6| 7| 8| 9| 10|
|
1311
1312
|
|11|12|13|14|15|16|17|18|19| 20|
|
@@ -1319,12 +1320,12 @@ result
|
|
1319
1320
|
|91|92|93|94|95|96|97|98|99|100|
|
1320
1321
|
~~~
|
1321
1322
|
|
1322
|
-
1 to 10 by 2 case
|
1323
|
+
1 to 10 by 2 case
|
1323
1324
|
~~~ruby
|
1324
1325
|
Fixnum.to_fixnum_table(1, 10, 2)
|
1325
1326
|
~~~
|
1326
1327
|
|
1327
|
-
result
|
1328
|
+
result
|
1328
1329
|
~~~
|
1329
1330
|
|1| 2|
|
1330
1331
|
|3| 4|
|
@@ -1342,7 +1343,7 @@ result
|
|
1342
1343
|
* ghost_method second_args = method_base_name Symbol(using in Ghostable internal logic)
|
1343
1344
|
* ghost_method third = block. this block is main logic. block can use args[method_name, *args, &block]
|
1344
1345
|
|
1345
|
-
sample ghost method define module.
|
1346
|
+
sample ghost method define module.
|
1346
1347
|
~~~ruby
|
1347
1348
|
require 'ghostable'
|
1348
1349
|
module Checkable
|
@@ -1366,7 +1367,7 @@ end
|
|
1366
1367
|
|
1367
1368
|
* use ghost method
|
1368
1369
|
|
1369
|
-
sample ghost method use class
|
1370
|
+
sample ghost method use class
|
1370
1371
|
~~~ruby
|
1371
1372
|
class SampleChecker
|
1372
1373
|
include Checkable
|
@@ -1432,7 +1433,7 @@ require 'tbpgr_utils'
|
|
1432
1433
|
}.html_table
|
1433
1434
|
~~~
|
1434
1435
|
|
1435
|
-
result
|
1436
|
+
result
|
1436
1437
|
|
1437
1438
|
~~~
|
1438
1439
|
<table>
|
@@ -1463,7 +1464,7 @@ require 'tbpgr_utils'
|
|
1463
1464
|
}.table
|
1464
1465
|
~~~
|
1465
1466
|
|
1466
|
-
result
|
1467
|
+
result
|
1467
1468
|
|
1468
1469
|
~~~ruby
|
1469
1470
|
|key_1 |value1___________________|
|
@@ -1513,7 +1514,7 @@ puts 1.blank? # => false
|
|
1513
1514
|
puts 1.present? # => true
|
1514
1515
|
~~~
|
1515
1516
|
|
1516
|
-
if you don't use bulk_define_methods, followinng code is same mean.
|
1517
|
+
if you don't use bulk_define_methods, followinng code is same mean.
|
1517
1518
|
~~~ruby
|
1518
1519
|
class NilClass
|
1519
1520
|
def blank?
|
@@ -1602,7 +1603,7 @@ person = Person.new
|
|
1602
1603
|
person.hash_to_attributes({name: 'hoge', age: 33})
|
1603
1604
|
~~~
|
1604
1605
|
|
1605
|
-
result
|
1606
|
+
result
|
1606
1607
|
~~~ruby
|
1607
1608
|
#<PersonForHashToAttributes:0x3957858 @age=33, @not_exists="hoge">
|
1608
1609
|
~~~
|
@@ -1627,7 +1628,7 @@ message = 'msg'
|
|
1627
1628
|
print_eval "hoge-#{message}", binding # => "hoge-#{message}" # => "hoge-msg"
|
1628
1629
|
~~~
|
1629
1630
|
|
1630
|
-
output
|
1631
|
+
output
|
1631
1632
|
~~~
|
1632
1633
|
8/4 # => 2"hoge-#{message}" # => "hoge-msg"
|
1633
1634
|
~~~
|
@@ -1644,7 +1645,7 @@ message = 'msg'
|
|
1644
1645
|
puts_eval "hoge-#{message}", binding # => "hoge-#{message}" # => "hoge-msg"
|
1645
1646
|
~~~
|
1646
1647
|
|
1647
|
-
output
|
1648
|
+
output
|
1648
1649
|
~~~
|
1649
1650
|
8/4 # => 2
|
1650
1651
|
"hoge-#{message}" # => "hoge-msg"
|
@@ -1663,7 +1664,7 @@ bulk_puts_eval binding, <<-EOS
|
|
1663
1664
|
EOS
|
1664
1665
|
~~~
|
1665
1666
|
|
1666
|
-
output
|
1667
|
+
output
|
1667
1668
|
~~~
|
1668
1669
|
"hoge-hige1" + "add" + message # => "hoge-hige1addmsg"
|
1669
1670
|
"hoge-hige2" + "add" + message # => "hoge-hige2addmsg"
|
@@ -1696,7 +1697,7 @@ end
|
|
1696
1697
|
EvalHelperAttrAccessorInitTest.new.hoge('atr1')
|
1697
1698
|
~~~
|
1698
1699
|
|
1699
|
-
result
|
1700
|
+
result
|
1700
1701
|
|
1701
1702
|
~~~ruby
|
1702
1703
|
attr_accessor :atr1
|
@@ -1720,7 +1721,7 @@ end
|
|
1720
1721
|
EvalHelperAttrAccessorInitTest.new.hoge(['atr1', 'atr2'])
|
1721
1722
|
~~~
|
1722
1723
|
|
1723
|
-
result
|
1724
|
+
result
|
1724
1725
|
|
1725
1726
|
~~~ruby
|
1726
1727
|
attr_accessor :atr1, :atr2
|
@@ -1987,7 +1988,7 @@ EvalHelperRequireRelativeTest.new.hoge(args) # => return "require_relative 'tbpg
|
|
1987
1988
|
[back to list](#list)
|
1988
1989
|
|
1989
1990
|
### EvalHelper#set_variable_code
|
1990
|
-
set string variable case
|
1991
|
+
set string variable case
|
1991
1992
|
~~~ruby
|
1992
1993
|
require 'eval_helper'
|
1993
1994
|
class EvalHelperSetVariableTest
|
@@ -2011,7 +2012,7 @@ return
|
|
2011
2012
|
hoge = "hoge"
|
2012
2013
|
~~~
|
2013
2014
|
|
2014
|
-
set numeric variable case
|
2015
|
+
set numeric variable case
|
2015
2016
|
~~~ruby
|
2016
2017
|
require 'eval_helper'
|
2017
2018
|
class EvalHelperSetVariableTest
|
@@ -2065,7 +2066,7 @@ EvalHelperSetVariablesTest.new.hoge(variables)
|
|
2065
2066
|
|
2066
2067
|
### EvalHelper#times_code
|
2067
2068
|
|
2068
|
-
single_line_proc case
|
2069
|
+
single_line_proc case
|
2069
2070
|
~~~ruby
|
2070
2071
|
require 'eval_helper'
|
2071
2072
|
|
@@ -2084,12 +2085,12 @@ hash = {
|
|
2084
2085
|
EvalHelperTimesTest.new.hoge(hash[:number], hash[:proc])
|
2085
2086
|
~~~
|
2086
2087
|
|
2087
|
-
return
|
2088
|
+
return
|
2088
2089
|
~~~
|
2089
2090
|
2.times { |i| puts "#{i}times" }
|
2090
2091
|
~~~
|
2091
2092
|
|
2092
|
-
multi_line_proc case
|
2093
|
+
multi_line_proc case
|
2093
2094
|
~~~ruby
|
2094
2095
|
require 'eval_helper'
|
2095
2096
|
|
@@ -2322,7 +2323,7 @@ Hoge.new.hege # => "hoge"
|
|
2322
2323
|
Hoge.new.huge # => "hoge"
|
2323
2324
|
~~~
|
2324
2325
|
|
2325
|
-
same code is...
|
2326
|
+
same code is...
|
2326
2327
|
~~~
|
2327
2328
|
class Hoge
|
2328
2329
|
def hoge
|
@@ -2374,7 +2375,7 @@ require 'tbpgr_utils'
|
|
2374
2375
|
|
2375
2376
|
### Numeric#is_ascii?
|
2376
2377
|
|
2377
|
-
1,127,128 case
|
2378
|
+
1,127,128 case
|
2378
2379
|
~~~ruby
|
2379
2380
|
require 'tbpgr_utils'
|
2380
2381
|
|
@@ -2393,7 +2394,7 @@ require 'tbpgr_utils'
|
|
2393
2394
|
Numeric.to_binary_html_table(255, 256)
|
2394
2395
|
~~~
|
2395
2396
|
|
2396
|
-
result
|
2397
|
+
result
|
2397
2398
|
~~~
|
2398
2399
|
<table>
|
2399
2400
|
<tr>
|
@@ -2420,7 +2421,7 @@ require 'tbpgr_utils'
|
|
2420
2421
|
Numeric.to_binary_table(1, 3)
|
2421
2422
|
~~~
|
2422
2423
|
|
2423
|
-
result
|
2424
|
+
result
|
2424
2425
|
~~~
|
2425
2426
|
|10digit|2digit |
|
2426
2427
|
|1 |00000001|
|
@@ -2437,7 +2438,7 @@ require 'tbpgr_utils'
|
|
2437
2438
|
Numeric.to_digit_html_table(255, 256)
|
2438
2439
|
~~~
|
2439
2440
|
|
2440
|
-
result
|
2441
|
+
result
|
2441
2442
|
~~~html
|
2442
2443
|
<table>
|
2443
2444
|
<tr>
|
@@ -2464,13 +2465,13 @@ result
|
|
2464
2465
|
[back to list](#list)
|
2465
2466
|
|
2466
2467
|
### Numeric to_digit_table
|
2467
|
-
255 to 256 case
|
2468
|
+
255 to 256 case
|
2468
2469
|
~~~ruby
|
2469
2470
|
require 'tbpgr_utils'
|
2470
2471
|
Numeric.to_digit_table(255, 256)
|
2471
2472
|
~~~
|
2472
2473
|
|
2473
|
-
result
|
2474
|
+
result
|
2474
2475
|
~~~
|
2475
2476
|
|10digit| 2digit|8digit|16digit|
|
2476
2477
|
| 255|0000000011111111| 377| 00ff|
|
@@ -2486,7 +2487,7 @@ require 'tbpgr_utils'
|
|
2486
2487
|
Numeric.to_hex_html_table(65535, 65536)
|
2487
2488
|
~~~
|
2488
2489
|
|
2489
|
-
result
|
2490
|
+
result
|
2490
2491
|
~~~
|
2491
2492
|
<table>
|
2492
2493
|
<tr>
|
@@ -2507,13 +2508,13 @@ result
|
|
2507
2508
|
[back to list](#list)
|
2508
2509
|
|
2509
2510
|
### Numeric to_hex_table
|
2510
|
-
65535 to 65536 case
|
2511
|
+
65535 to 65536 case
|
2511
2512
|
~~~ruby
|
2512
2513
|
require 'tbpgr_utils'
|
2513
2514
|
Numeric.to_hex_table(65535, 65536)
|
2514
2515
|
~~~
|
2515
2516
|
|
2516
|
-
result
|
2517
|
+
result
|
2517
2518
|
~~~
|
2518
2519
|
|10digit| 16digit|
|
2519
2520
|
| 65535|0000ffff|
|
@@ -2523,13 +2524,13 @@ result
|
|
2523
2524
|
[back to list](#list)
|
2524
2525
|
|
2525
2526
|
### Numeric to_oct_html_table
|
2526
|
-
65535 to 65536 case
|
2527
|
+
65535 to 65536 case
|
2527
2528
|
~~~ruby
|
2528
2529
|
require 'tbpgr_utils'
|
2529
2530
|
Numeric.to_oct_html_table(65535, 65536)
|
2530
2531
|
~~~
|
2531
2532
|
|
2532
|
-
result
|
2533
|
+
result
|
2533
2534
|
~~~
|
2534
2535
|
<table>
|
2535
2536
|
<tr>
|
@@ -2550,13 +2551,13 @@ result
|
|
2550
2551
|
[back to list](#list)
|
2551
2552
|
|
2552
2553
|
### Numeric to_oct_table
|
2553
|
-
65535 to 65536 case
|
2554
|
+
65535 to 65536 case
|
2554
2555
|
~~~ruby
|
2555
2556
|
require 'tbpgr_utils'
|
2556
2557
|
Numeric.to_oct_table(65535, 65536)
|
2557
2558
|
~~~
|
2558
2559
|
|
2559
|
-
result
|
2560
|
+
result
|
2560
2561
|
~~~
|
2561
2562
|
|10digit|8digit|
|
2562
2563
|
| 65535|177777|
|
@@ -2752,6 +2753,45 @@ require 'tbpgr_utils'
|
|
2752
2753
|
|
2753
2754
|
[back to list](#list)
|
2754
2755
|
|
2756
|
+
### String#ascii_unicode_html_table
|
2757
|
+
~~~ruby
|
2758
|
+
require 'tbpgr_utils'
|
2759
|
+
|
2760
|
+
'aあb'.ascii_unicode_html_table
|
2761
|
+
~~~
|
2762
|
+
|
2763
|
+
result
|
2764
|
+
~~~
|
2765
|
+
<table>
|
2766
|
+
<tr>
|
2767
|
+
<th>char</th>
|
2768
|
+
<th>ASCII</th>
|
2769
|
+
<th>ascii2</th>
|
2770
|
+
<th>Unicode</th>
|
2771
|
+
</tr>
|
2772
|
+
<tr>
|
2773
|
+
<td>a</td>
|
2774
|
+
<td>97</td>
|
2775
|
+
<td>1100001</td>
|
2776
|
+
<td>--</td>
|
2777
|
+
</tr>
|
2778
|
+
<tr>
|
2779
|
+
<td>あ</td>
|
2780
|
+
<td>--</td>
|
2781
|
+
<td>--</td>
|
2782
|
+
<td>0x3042</td>
|
2783
|
+
</tr>
|
2784
|
+
<tr>
|
2785
|
+
<td>b</td>
|
2786
|
+
<td>98</td>
|
2787
|
+
<td>1100010</td>
|
2788
|
+
<td>--</td>
|
2789
|
+
</tr>
|
2790
|
+
</table>
|
2791
|
+
~~~
|
2792
|
+
|
2793
|
+
[back to list](#list)
|
2794
|
+
|
2755
2795
|
### String#ascii_unicode_table
|
2756
2796
|
~~~ruby
|
2757
2797
|
require 'tbpgr_utils'
|
@@ -2759,7 +2799,7 @@ require 'tbpgr_utils'
|
|
2759
2799
|
'aあb'.ascii_unicode_table
|
2760
2800
|
~~~
|
2761
2801
|
|
2762
|
-
result
|
2802
|
+
result
|
2763
2803
|
~~~
|
2764
2804
|
|char|ASCII|ascii2 |Unicode|
|
2765
2805
|
| a | 97 |1100001| -- |
|
@@ -2853,27 +2893,27 @@ output
|
|
2853
2893
|
[back to list](#list)
|
2854
2894
|
|
2855
2895
|
### String#say
|
2856
|
-
default case
|
2896
|
+
default case
|
2857
2897
|
~~~ruby
|
2858
2898
|
'hoge'.say # => 'hoge'
|
2859
2899
|
~~~
|
2860
2900
|
|
2861
|
-
quote case
|
2901
|
+
quote case
|
2862
2902
|
~~~ruby
|
2863
2903
|
'hoge'.say(:quote) # => 'hoge'
|
2864
2904
|
~~~
|
2865
2905
|
|
2866
|
-
dquote case
|
2906
|
+
dquote case
|
2867
2907
|
~~~ruby
|
2868
2908
|
'hoge'.say(:dquote) # => "hoge"
|
2869
2909
|
~~~
|
2870
2910
|
|
2871
|
-
bracket case
|
2911
|
+
bracket case
|
2872
2912
|
~~~ruby
|
2873
2913
|
'hoge'.say(:bracket) # => [hoge]
|
2874
2914
|
~~~
|
2875
2915
|
|
2876
|
-
hyphen case
|
2916
|
+
hyphen case
|
2877
2917
|
~~~ruby
|
2878
2918
|
'hoge'.say(:hyphen) # => -hoge-
|
2879
2919
|
~~~
|
@@ -2891,28 +2931,28 @@ hoge.spacing({char: '_', size: 2}) # => 'h__o__g__e'
|
|
2891
2931
|
[back to list](#list)
|
2892
2932
|
|
2893
2933
|
### String#stripe
|
2894
|
-
default case
|
2934
|
+
default case
|
2895
2935
|
~~~ ruby
|
2896
2936
|
require 'tbpgr_utils'
|
2897
2937
|
|
2898
2938
|
'hoge'.stripe # => HoGe
|
2899
2939
|
~~~
|
2900
2940
|
|
2901
|
-
lower_cap case
|
2941
|
+
lower_cap case
|
2902
2942
|
~~~ruby
|
2903
2943
|
require 'tbpgr_utils'
|
2904
2944
|
|
2905
2945
|
'hoge'.stripe :lower_cap # => hOgE
|
2906
2946
|
~~~
|
2907
2947
|
|
2908
|
-
empty case
|
2948
|
+
empty case
|
2909
2949
|
~~~ruby
|
2910
2950
|
require 'tbpgr_utils'
|
2911
2951
|
|
2912
2952
|
''.stripe # => ''
|
2913
2953
|
~~~
|
2914
2954
|
|
2915
|
-
nil case
|
2955
|
+
nil case
|
2916
2956
|
~~~ruby
|
2917
2957
|
require 'tbpgr_utils'
|
2918
2958
|
|
@@ -2930,7 +2970,7 @@ require 'tbpgr_utils'
|
|
2930
2970
|
'hoge'.surround
|
2931
2971
|
~~~
|
2932
2972
|
|
2933
|
-
result
|
2973
|
+
result
|
2934
2974
|
|
2935
2975
|
~~~
|
2936
2976
|
------
|
@@ -2945,7 +2985,7 @@ require 'tbpgr_utils'
|
|
2945
2985
|
"hoge\na".surround
|
2946
2986
|
~~~
|
2947
2987
|
|
2948
|
-
result
|
2988
|
+
result
|
2949
2989
|
|
2950
2990
|
~~~
|
2951
2991
|
------
|
@@ -2961,7 +3001,7 @@ require 'tbpgr_utils'
|
|
2961
3001
|
'hoge'.surround top_bottom: '=', side: '!'
|
2962
3002
|
~~~
|
2963
3003
|
|
2964
|
-
result
|
3004
|
+
result
|
2965
3005
|
|
2966
3006
|
~~~
|
2967
3007
|
======
|
@@ -2983,7 +3023,7 @@ EOS
|
|
2983
3023
|
BEFORE.table_to_array
|
2984
3024
|
~~~
|
2985
3025
|
|
2986
|
-
result
|
3026
|
+
result
|
2987
3027
|
~~~ruby
|
2988
3028
|
[["header1", "header2", "header3"], ["line1_1", "line1_2", "line1_3"]]
|
2989
3029
|
~~~
|
@@ -2991,20 +3031,20 @@ result
|
|
2991
3031
|
[back to list](#list)
|
2992
3032
|
|
2993
3033
|
### String#to_hatena_heading
|
2994
|
-
> case
|
3034
|
+
> case
|
2995
3035
|
~~~ruby
|
2996
3036
|
require 'tbpgr_utils'
|
2997
3037
|
'hoge>hige'.to_hatena_heading # => '*hoge\n**hige'
|
2998
3038
|
~~~
|
2999
3039
|
|
3000
|
-
\+ case
|
3040
|
+
\+ case
|
3001
3041
|
~~~ruby
|
3002
3042
|
require 'tbpgr_utils'
|
3003
3043
|
|
3004
3044
|
'hoge+hige'.to_hatena_heading # => '*hoge\n*hige'
|
3005
3045
|
~~~
|
3006
3046
|
|
3007
|
-
^ case
|
3047
|
+
^ case
|
3008
3048
|
~~~ruby
|
3009
3049
|
require 'tbpgr_utils'
|
3010
3050
|
'hoge>hige^hege'.to_hatena_heading # => '*hoge\n**hige\n*hege'
|
@@ -3013,20 +3053,20 @@ require 'tbpgr_utils'
|
|
3013
3053
|
[back to list](#list)
|
3014
3054
|
|
3015
3055
|
### String#to_markdown_heading
|
3016
|
-
> case
|
3056
|
+
> case
|
3017
3057
|
~~~ruby
|
3018
3058
|
require 'tbpgr_utils'
|
3019
3059
|
'hoge>hige'.to_markdown_heading # => '# hoge\n## hige'
|
3020
3060
|
~~~
|
3021
3061
|
|
3022
|
-
\+ case
|
3062
|
+
\+ case
|
3023
3063
|
~~~ruby
|
3024
3064
|
require 'tbpgr_utils'
|
3025
3065
|
|
3026
3066
|
'hoge+hige'.to_markdown_heading # => '# hoge\n# hige'
|
3027
3067
|
~~~
|
3028
3068
|
|
3029
|
-
^ case
|
3069
|
+
^ case
|
3030
3070
|
~~~ruby
|
3031
3071
|
require 'tbpgr_utils'
|
3032
3072
|
'hoge>hige^hege'.to_markdown_heading # => '# hoge\n## hige\n# hege'
|
@@ -3035,20 +3075,20 @@ require 'tbpgr_utils'
|
|
3035
3075
|
[back to list](#list)
|
3036
3076
|
|
3037
3077
|
### String#to_space2_heading
|
3038
|
-
> case
|
3078
|
+
> case
|
3039
3079
|
~~~ruby
|
3040
3080
|
require 'tbpgr_utils'
|
3041
3081
|
'hoge>hige'.to_space2_heading # => 'hoge\n hige'
|
3042
3082
|
~~~
|
3043
3083
|
|
3044
|
-
\+ case
|
3084
|
+
\+ case
|
3045
3085
|
~~~ruby
|
3046
3086
|
require 'tbpgr_utils'
|
3047
3087
|
|
3048
3088
|
'hoge+hige'.to_space2_heading # => 'hoge\nhige'
|
3049
3089
|
~~~
|
3050
3090
|
|
3051
|
-
^ case
|
3091
|
+
^ case
|
3052
3092
|
~~~ruby
|
3053
3093
|
require 'tbpgr_utils'
|
3054
3094
|
'hoge>hige^hege'.to_space2_heading # => 'hoge\n hige\nhege'
|
@@ -3057,19 +3097,19 @@ require 'tbpgr_utils'
|
|
3057
3097
|
[back to list](#list)
|
3058
3098
|
|
3059
3099
|
### String#to_space4_heading
|
3060
|
-
> case
|
3100
|
+
> case
|
3061
3101
|
~~~ruby
|
3062
3102
|
require 'tbpgr_utils'
|
3063
3103
|
'hoge>hige'.to_space4_heading # => 'hoge\n hige'
|
3064
3104
|
~~~
|
3065
3105
|
|
3066
|
-
\+ case
|
3106
|
+
\+ case
|
3067
3107
|
~~~ruby
|
3068
3108
|
require 'tbpgr_utils'
|
3069
3109
|
'hoge+hige'.to_space4_heading # => 'hoge\nhige'
|
3070
3110
|
~~~
|
3071
3111
|
|
3072
|
-
^ case
|
3112
|
+
^ case
|
3073
3113
|
~~~ruby
|
3074
3114
|
require 'tbpgr_utils'
|
3075
3115
|
'hoge>hige^hege'.to_space4_heading # => 'hoge\n hige\nhege'
|
@@ -3078,19 +3118,19 @@ require 'tbpgr_utils'
|
|
3078
3118
|
[back to list](#list)
|
3079
3119
|
|
3080
3120
|
### String#to_tab_heading
|
3081
|
-
> case
|
3121
|
+
> case
|
3082
3122
|
~~~ruby
|
3083
3123
|
require 'tbpgr_utils'
|
3084
3124
|
'hoge>hige'.to_tab_heading # => 'hoge\n\thige'
|
3085
3125
|
~~~
|
3086
3126
|
|
3087
|
-
\+ case
|
3127
|
+
\+ case
|
3088
3128
|
~~~ruby
|
3089
3129
|
require 'tbpgr_utils'
|
3090
3130
|
'hoge+hige'.to_tab_heading # => 'hoge\nhige'
|
3091
3131
|
~~~
|
3092
3132
|
|
3093
|
-
^ case
|
3133
|
+
^ case
|
3094
3134
|
~~~ruby
|
3095
3135
|
require 'tbpgr_utils'
|
3096
3136
|
'hoge>hige^hege'.to_tab_heading # => 'hoge\n\thige\nhege'
|
@@ -3151,10 +3191,10 @@ line2:<%=placeholders[:hige]%>
|
|
3151
3191
|
end
|
3152
3192
|
end
|
3153
3193
|
|
3154
|
-
p TemplateUser.new('sample').result
|
3194
|
+
p TemplateUser.new('sample').result
|
3155
3195
|
~~~
|
3156
3196
|
|
3157
|
-
output
|
3197
|
+
output
|
3158
3198
|
~~~
|
3159
3199
|
line1:hoge-sample
|
3160
3200
|
line2:hige-sample
|
@@ -3224,6 +3264,7 @@ if you are Sublime Text2 user, you can use snippet for TbpgrUtils.
|
|
3224
3264
|
https://github.com/tbpgr/tbpgr_utils_snippets
|
3225
3265
|
|
3226
3266
|
## History
|
3267
|
+
* version 0.0.100 : add String.ascii_unicode_html_table
|
3227
3268
|
* version 0.0.99 : add Numeric.to_oct_html_table
|
3228
3269
|
* version 0.0.98 : add Numeric.to_hex_html_table
|
3229
3270
|
* version 0.0.97 : add Numeric.to_digit_html_table
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'open_classes/numeric/is_ascii'
|
3
|
+
require 'open_classes/string/ascii1_other2_size'
|
4
|
+
|
5
|
+
# String
|
6
|
+
class String
|
7
|
+
# get ascii_unicode_table
|
8
|
+
#
|
9
|
+
# === Example
|
10
|
+
#
|
11
|
+
# input
|
12
|
+
# 'aあb'
|
13
|
+
#
|
14
|
+
# result
|
15
|
+
#
|
16
|
+
# <table>
|
17
|
+
# <tr>
|
18
|
+
# <th>char</th>
|
19
|
+
# <th>ASCII</th>
|
20
|
+
# <th>ascii2</th>
|
21
|
+
# <th>Unicode</th>
|
22
|
+
# </tr>
|
23
|
+
# <tr>
|
24
|
+
# <td>a</td>
|
25
|
+
# <td>97</td>
|
26
|
+
# <td>1100001</td>
|
27
|
+
# <td>--</td>
|
28
|
+
# </tr>
|
29
|
+
# <tr>
|
30
|
+
# <td>あ</td>
|
31
|
+
# <td>--</td>
|
32
|
+
# <td>--</td>
|
33
|
+
# <td>0x3042</td>
|
34
|
+
# </tr>
|
35
|
+
# <tr>
|
36
|
+
# <td>b</td>
|
37
|
+
# <td>98</td>
|
38
|
+
# <td>1100010</td>
|
39
|
+
# <td>--</td>
|
40
|
+
# </tr>
|
41
|
+
# </table>
|
42
|
+
#
|
43
|
+
def ascii_unicode_html_table
|
44
|
+
ret = ["<table>\n <tr>\n <th>char</th>\n <th>ASCII</th>\n <th>ascii2</th>\n <th>Unicode</th>\n </tr>"]
|
45
|
+
chars.each do |c|
|
46
|
+
each_ret = []
|
47
|
+
each_ret << " <tr>\n <td>#{c}</td>"
|
48
|
+
if c.ord.is_ascii?
|
49
|
+
each_ret << " <td>#{c.ord}</td>"
|
50
|
+
each_ret << " <td>#{c.ord.to_s(2)}</td>"
|
51
|
+
each_ret << " <td>--</td>\n </tr>"
|
52
|
+
else
|
53
|
+
each_ret << ' <td>--</td>'
|
54
|
+
each_ret << ' <td>--</td>'
|
55
|
+
each_ret << " <td>0x#{c.ord.to_s(16)}</td>\n </tr>"
|
56
|
+
end
|
57
|
+
ret << each_ret.join("\n")
|
58
|
+
end
|
59
|
+
(ret.join("\n") + "\n</table>\n")
|
60
|
+
end
|
61
|
+
end
|
data/lib/open_classes/string.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'open_classes/string/ascii1_other2_size'
|
3
3
|
require 'open_classes/string/ascii_unicode_table'
|
4
|
+
require 'open_classes/string/ascii_unicode_html_table'
|
4
5
|
require 'open_classes/string/comma_to_a'
|
5
6
|
require 'open_classes/string/escape_double_quote'
|
6
7
|
require 'open_classes/string/escape_quote'
|
data/lib/tbpgr_utils/version.rb
CHANGED
@@ -11,7 +11,7 @@ describe Familyable::Family do
|
|
11
11
|
persons: [
|
12
12
|
a = Familyable::Person.new(id: 1, parent_ids: [2, 3]),
|
13
13
|
b = Familyable::Person.new(id: 2, parent_ids: []),
|
14
|
-
c = Familyable::Person.new(id: 3, parent_ids: [4],
|
14
|
+
c = Familyable::Person.new(id: 3, parent_ids: [4],),
|
15
15
|
d = Familyable::Person.new(id: 4, parent_ids: []),
|
16
16
|
e = Familyable::Person.new(id: 5, parent_ids: [2]),
|
17
17
|
],
|
@@ -59,7 +59,7 @@ describe Familyable::Family do
|
|
59
59
|
persons: [
|
60
60
|
a = Familyable::Person.new(id: 1, parent_ids: [2, 3]),
|
61
61
|
b = Familyable::Person.new(id: 2, parent_ids: []),
|
62
|
-
c = Familyable::Person.new(id: 3, parent_ids: [4],
|
62
|
+
c = Familyable::Person.new(id: 3, parent_ids: [4],),
|
63
63
|
d = Familyable::Person.new(id: 4, parent_ids: []),
|
64
64
|
e = Familyable::Person.new(id: 5, parent_ids: [2]),
|
65
65
|
],
|
@@ -107,7 +107,7 @@ describe Familyable::Family do
|
|
107
107
|
persons: [
|
108
108
|
a = Familyable::Person.new(id: 1, parent_ids: [2, 3]),
|
109
109
|
b = Familyable::Person.new(id: 2, parent_ids: []),
|
110
|
-
c = Familyable::Person.new(id: 3, parent_ids: [4],
|
110
|
+
c = Familyable::Person.new(id: 3, parent_ids: [4],),
|
111
111
|
d = Familyable::Person.new(id: 4, parent_ids: [3]),
|
112
112
|
e = Familyable::Person.new(id: 5, parent_ids: [2]),
|
113
113
|
],
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'open_classes/string/ascii_unicode_html_table'
|
4
|
+
|
5
|
+
describe String do
|
6
|
+
context :ascii_unicode_html_table do
|
7
|
+
cases = [
|
8
|
+
{
|
9
|
+
case_no: 1,
|
10
|
+
case_title: '> case',
|
11
|
+
input: 'aあb',
|
12
|
+
expected: <<-EOS
|
13
|
+
<table>
|
14
|
+
<tr>
|
15
|
+
<th>char</th>
|
16
|
+
<th>ASCII</th>
|
17
|
+
<th>ascii2</th>
|
18
|
+
<th>Unicode</th>
|
19
|
+
</tr>
|
20
|
+
<tr>
|
21
|
+
<td>a</td>
|
22
|
+
<td>97</td>
|
23
|
+
<td>1100001</td>
|
24
|
+
<td>--</td>
|
25
|
+
</tr>
|
26
|
+
<tr>
|
27
|
+
<td>あ</td>
|
28
|
+
<td>--</td>
|
29
|
+
<td>--</td>
|
30
|
+
<td>0x3042</td>
|
31
|
+
</tr>
|
32
|
+
<tr>
|
33
|
+
<td>b</td>
|
34
|
+
<td>98</td>
|
35
|
+
<td>1100010</td>
|
36
|
+
<td>--</td>
|
37
|
+
</tr>
|
38
|
+
</table>
|
39
|
+
EOS
|
40
|
+
},
|
41
|
+
]
|
42
|
+
|
43
|
+
cases.each do |c|
|
44
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
45
|
+
begin
|
46
|
+
case_before c
|
47
|
+
|
48
|
+
# -- given --
|
49
|
+
# nothing
|
50
|
+
|
51
|
+
# -- when --
|
52
|
+
actual = c[:input].ascii_unicode_html_table
|
53
|
+
|
54
|
+
# -- then --
|
55
|
+
expect(actual).to eq(c[:expected])
|
56
|
+
ensure
|
57
|
+
case_after c
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def case_before(c)
|
62
|
+
# implement each case before
|
63
|
+
end
|
64
|
+
|
65
|
+
def case_after(c)
|
66
|
+
# implement each case after
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tbpgr_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.100
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-04-
|
12
|
+
date: 2014-04-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &21875244 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 4.0.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *21875244
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &21874500 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '1.3'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *21874500
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &21872964 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *21872964
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &21872436 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 2.14.1
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *21872436
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: simplecov
|
60
|
-
requirement: &
|
60
|
+
requirement: &21871812 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: 0.8.2
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *21871812
|
69
69
|
description: Utilities
|
70
70
|
email:
|
71
71
|
- tbpgr@tbpgr.jp
|
@@ -176,6 +176,7 @@ files:
|
|
176
176
|
- lib/open_classes/object/to_bool.rb
|
177
177
|
- lib/open_classes/string.rb
|
178
178
|
- lib/open_classes/string/ascii1_other2_size.rb
|
179
|
+
- lib/open_classes/string/ascii_unicode_html_table.rb
|
179
180
|
- lib/open_classes/string/ascii_unicode_table.rb
|
180
181
|
- lib/open_classes/string/comma_to_a.rb
|
181
182
|
- lib/open_classes/string/escape_double_quote.rb
|
@@ -287,6 +288,7 @@ files:
|
|
287
288
|
- spec/open_classes/object/null_spec.rb
|
288
289
|
- spec/open_classes/object/to_bool_spec.rb
|
289
290
|
- spec/open_classes/string/ascii1_other2_size_spec.rb
|
291
|
+
- spec/open_classes/string/ascii_unicode_html_table_spec.rb
|
290
292
|
- spec/open_classes/string/ascii_unicode_table_spec.rb
|
291
293
|
- spec/open_classes/string/comma_to_a_spec.rb
|
292
294
|
- spec/open_classes/string/escape_double_quote_spec.rb
|
@@ -421,6 +423,7 @@ test_files:
|
|
421
423
|
- spec/open_classes/object/null_spec.rb
|
422
424
|
- spec/open_classes/object/to_bool_spec.rb
|
423
425
|
- spec/open_classes/string/ascii1_other2_size_spec.rb
|
426
|
+
- spec/open_classes/string/ascii_unicode_html_table_spec.rb
|
424
427
|
- spec/open_classes/string/ascii_unicode_table_spec.rb
|
425
428
|
- spec/open_classes/string/comma_to_a_spec.rb
|
426
429
|
- spec/open_classes/string/escape_double_quote_spec.rb
|