├── main.rb ├── Loops_infinate.rb ├── Loops_while_unitl.rb ├── load_class.rb ├── Simple_if.rb ├── simple_unles.rb ├── debug.rb ├── Loops_while.rb ├── my_age_determine.rb ├── .idea ├── vcs.xml ├── modules.xml ├── misc.xml ├── RubyTutorials.iml └── workspace.xml ├── Loops_until.rb ├── Nested_if.rb ├── Loops_for.rb ├── README.md ├── Loops_control.rb ├── simple_case.rb ├── LocalVS.rb ├── class_ins.rb ├── Loops_ruby.rb ├── Condation_if_else.rb ├── model.rb ├── class_simple.rb ├── class_init.rb ├── model2.rb ├── class_override.rb ├── clas_inher.rb ├── methods.rb └── class_properties.rb /main.rb: -------------------------------------------------------------------------------- 1 | puts 12345 2 | -------------------------------------------------------------------------------- /Loops_infinate.rb: -------------------------------------------------------------------------------- 1 | 2 | num=10 3 | while num>1 4 | puts num 5 | num+=1 6 | end -------------------------------------------------------------------------------- /Loops_while_unitl.rb: -------------------------------------------------------------------------------- 1 | num=1 2 | 3 | begin 4 | puts "hi" 5 | num-=1 6 | end while num>1 7 | 8 | puts "loop is done" -------------------------------------------------------------------------------- /load_class.rb: -------------------------------------------------------------------------------- 1 | load 'class_simple.rb' 2 | 3 | owner1=Car.new 4 | owner1.set_owner("jena alrubaye") 5 | owner1.get_owner -------------------------------------------------------------------------------- /Simple_if.rb: -------------------------------------------------------------------------------- 1 | num=10 2 | if num % 2==0 3 | # block of code 4 | puts "number is even" 5 | else 6 | puts "number is odd" 7 | end 8 | puts "Program is done" -------------------------------------------------------------------------------- /simple_unles.rb: -------------------------------------------------------------------------------- 1 | num=9 2 | unless num % 2==0 3 | # block of code 4 | puts "number is odd" 5 | 6 | else 7 | puts "number is even" 8 | end 9 | puts "Program is done" -------------------------------------------------------------------------------- /debug.rb: -------------------------------------------------------------------------------- 1 | # this hold user id 2 | user_id=2 3 | #this hold user name who login to the system 4 | user_name="hussein alrubaye" 5 | user_dbo=1990 6 | puts("user name is #{user_name}") -------------------------------------------------------------------------------- /Loops_while.rb: -------------------------------------------------------------------------------- 1 | 2 | num=1 3 | while num<5 4 | #block of code 5 | puts num 6 | if num ==2 7 | puts "number is 2" 8 | end 9 | num+=1 #num=num+1 10 | end 11 | 12 | puts "loop is done" -------------------------------------------------------------------------------- /my_age_determine.rb: -------------------------------------------------------------------------------- 1 | require 'date' 2 | puts("enter your DOB") 3 | user_dob=gets.chomp.to_i 4 | year_now=Time.now.year.to_i 5 | user_age=year_now-user_dob 6 | puts("your age is #{user_age} Year") 7 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Loops_until.rb: -------------------------------------------------------------------------------- 1 | 2 | num=1 3 | until num==5 4 | #block of code 5 | puts num 6 | if num ==2 7 | puts "number is 2" 8 | end 9 | num+=1 #num=num+1 10 | end 11 | 12 | puts "loop is done" 13 | -------------------------------------------------------------------------------- /Nested_if.rb: -------------------------------------------------------------------------------- 1 | num=4 2 | if num % 2==0 3 | # block of code 4 | puts "number is even" 5 | if num>5 6 | puts " large than 5" 7 | else 8 | puts " less than 5" 9 | end 10 | end 11 | puts "Program is done" -------------------------------------------------------------------------------- /Loops_for.rb: -------------------------------------------------------------------------------- 1 | 2 | accounts=["admin","developer","users","customer"] 3 | 4 | for account_type in accounts 5 | puts account_type 6 | end 7 | 8 | # counter 9 | for index in (0..3) 10 | puts accounts[index] 11 | 12 | end -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ruby Tutorial essential Training 2 | ###This code is snapped code for this [Ruby Youtube playlist](https://www.youtube.com/playlist?list=PLF8OvnCBlEY0GJVVe1YquY64Ag7NBbPZq) 3 | To make the learn and writing code easy 4 | -------------------------------------------------------------------------------- /Loops_control.rb: -------------------------------------------------------------------------------- 1 | 2 | accounts=["admin","developer","users","customer"] 3 | 4 | # counter 5 | for index in (0..3) 6 | if accounts[index]==accounts[2] 7 | next 8 | end 9 | puts accounts[index] 10 | 11 | end 12 | 13 | puts "end app" -------------------------------------------------------------------------------- /simple_case.rb: -------------------------------------------------------------------------------- 1 | num=5 2 | 3 | case num 4 | when 5 5 | puts "is five" 6 | when 6 7 | puts "is six" 8 | when 7 9 | puts "is seven" 10 | when 8..100 11 | puts "between eighn and one hundered" 12 | else 13 | puts "out of range" 14 | end -------------------------------------------------------------------------------- /LocalVS.rb: -------------------------------------------------------------------------------- 1 | num=10 2 | 3 | puts "number is #{num}" 4 | 5 | 6 | (1..10).each{ 7 | block_var=10 8 | #block ,for,loop,while,if ,iteror 9 | puts "number in block is #{num}" 10 | puts "bolck var#{block_var}" 11 | } 12 | 13 | puts "bolck var#{block_var}" 14 | 15 | 16 | -------------------------------------------------------------------------------- /class_ins.rb: -------------------------------------------------------------------------------- 1 | 2 | class Car 3 | def get_owner 4 | puts @@ownerC 5 | end 6 | 7 | def self.set_owner(owner) 8 | @@ownerC=owner 9 | end 10 | 11 | end 12 | 13 | 14 | 15 | 16 | 17 | # var //local 18 | # $var // global 19 | # @var // instance of class 20 | # @@var // of class -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Loops_ruby.rb: -------------------------------------------------------------------------------- 1 | 2 | #1 3 | (5).times do 4 | #blck of code 5 | puts "hi times" 6 | end 7 | #2 8 | 1.upto(5) do |i| 9 | #blck of code 10 | puts "upto #{i}" 11 | end 12 | #2 13 | 5.downto(1) do |i| 14 | #blck of code 15 | puts "downto #{i}" 16 | end 17 | 18 | 19 | #3 20 | (1..10).each{ |i| 21 | #blck of code 22 | puts "each #{i}" 23 | } 24 | -------------------------------------------------------------------------------- /Condation_if_else.rb: -------------------------------------------------------------------------------- 1 | num =110 2 | 3 | if num <50 4 | puts "fail" 5 | elsif num >=50 && num <=60 6 | puts "E" 7 | elsif num >60 && num <=70 8 | puts "D" 9 | elsif num >70 && num <=80 10 | puts "C" 11 | elsif num >80 && num <=90 12 | puts "B" 13 | elsif num >90 && num <=100 14 | puts "A" 15 | else 16 | puts "out of range" 17 | end 18 | puts "progam done" -------------------------------------------------------------------------------- /model.rb: -------------------------------------------------------------------------------- 1 | module Info 2 | 3 | class Car 4 | def get_owner 5 | puts @ownerC 6 | end 7 | 8 | def set_owner(owner) 9 | @ownerC=owner 10 | end 11 | 12 | end 13 | 14 | class Dmv 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.idea/RubyTutorials.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 174 | 175 | 207 | 208 | 209 | 210 | 211 | true 212 | DEFINITION_ORDER 213 | 214 | 215 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 252 | 253 | 254 | 255 | 258 | 259 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | project 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 521 | 522 | 523 | 524 | 1467532433580 525 | 537 | 538 | 539 | 540 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 587 | 588 | 589 | 590 | 591 | file://$PROJECT_DIR$/Simple_if.rb 592 | 594 | 595 | file://$PROJECT_DIR$/Condation_if_else.rb 596 | 598 | 599 | file://$PROJECT_DIR$/simple_unles.rb 600 | 602 | 603 | file://$PROJECT_DIR$/simple_case.rb 604 | 606 | 607 | file://$PROJECT_DIR$/Nested_if.rb 608 | 610 | 611 | file://$PROJECT_DIR$/Loops_for.rb 612 | 1 613 | 615 | 616 | file://$PROJECT_DIR$/clas_inher.rb 617 | 2 618 | 620 | 621 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 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 | 776 | 777 | 778 | 779 | 780 | 781 | 782 | 783 | 784 | 785 | 786 | 787 | 788 | 789 | 790 | 791 | 792 | 793 | 794 | 795 | 796 | 797 | 798 | 799 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 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 | 865 | 866 | 867 | 868 | 869 | 870 | 871 | 872 | 873 | 874 | 875 | 876 | 877 | 878 | 879 | 880 | 881 | 882 | 883 | 884 | 885 | 886 | 887 | 888 | 889 | 890 | 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 | 970 | 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 | --------------------------------------------------------------------------------