<commit_before><!DOCTYPE html>
<html>
  <head>
    <title><NAME></title>
    <meta charset="utf-8">
    <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" /> 
    <link rel="stylesheet" href="../stylesheets/default.css">
    <link rel="stylesheet" href="../stylesheets/blog.css">
    <link href="../stylesheets/prism.css" rel="stylesheet" />
  </head>
  <body>
    <header class="header-wrap">      
      <h1 class="name-logo"><a class="nav-link top-nav-link" href="../index.html"><NAME></a></h1>
      <nav class="top-nav">
        <ul class="nav-list">
          <li class="nav-item"><a class="nav-link top-nav-link" href="../portfolio/portfolio.html">Portfolio</a></li>
          <li class="nav-item"><a class="nav-link top-nav-link current-page" href="blog-index.html">Blog</a></li>
        </ul>
      </nav>      
      <section class="intro-greeting">          
        <h2 class="current-page page-header">Don't Hate, Enumberate</h2>
        <h3 class="sub-title">LETS GET SOME POWER-UPS</h3>
        <h4>xx/xx/xxxx</h4>
        <nav class="arrow-nav intro-greeting-last">
          <ul class="nav-list">
            <li class="nav-item"><a class="nav-link top-nav-link" href="arrays-hashes.html" title="prev blog">&#9664;</a></li>
            <li class="nav-item"><a class="nav-link top-nav-link" href="blog-index.html" title="back">&#9650;</a></li>              
            <li class="nav-item"><a class="nav-link top-nav-link" href="git.html" title="next blog">&#9658;</a></li>              
          </ul>            
        </nav>
      </section>
    </header>
    <div class="text-width">
      <article class="main-content">
        <figure>
          <img src="../imgs/beasty_boys.jpg" alt="Num Num Arrays are Yummy">
          <figcaption>What do you mean you forgot the fish-eye lens?...</figcaption>
        </figure>              
        
        <h3 class="blog-header">Enumberables Everyone!</h3>
        <p class="blog-text">Enermable is a <em>mixin</em> that allows collection classes,
        like Arrays and Hashes, the ability to easily traverse, search and sort within themselfs 
        throught the use of the mixins methods.</p>
        <h3 class="blog-header">Whats a mixin?</h3>
        <p class="blog-text">Mixins are <em><a href="#">Modules</a></em> that are "missed in" to a class,givin
        that Class access to the Modules methods. Mixins are like a power upgrades in Mario; You can give your Array fire-power, and give your Hashes Yoshi! Mixins 
        allow for a class to inherit functionality from multiple sources; this is good becuase Ruby only allows
        <em>single inheritance</em>; mixins are a sort-of work around that.</p>
        <h3 class="blog-header">Back To Enumberables</h3>
        <p class="blog-text">Enumerable offers many <em>very</em> useful <a href="http://ruby-doc.org/core-2.2.3/Enumerable.html">methods</a>
        These methods have differant iterations for Arrays and Hashes. like here is the Enumerable#each method being used 
        with an Array then with a Hash:</p>
        <code class="language-ruby">mario_characters = [Mario, Yoshi, Bowser, Peach, Toad]</code>
         <code class="language-ruby">character_size = { Mario: 'Medium', Yoshi: 'Medium', Bowser: 'Large',
         Peach: 'Medium', Toad: 'Small'}</code>
        <code class="language-ruby">mario_characters.each { |char| puts char}</code>
        <code class="language-ruby">Mario</code>
        <code class="language-ruby">Yoshi</code>
        <code class="language-ruby">Bowser</code>
        <code class="language-ruby">Peach</code>
        <code class="language-ruby">Toad</code>
        <code class="language-ruby"> </code>
        <code class="language-ruby">character_size.each { |char, size| puts "#{char}: #{size}"}</code>
        <code class="language-ruby">Mario: Medium</code>
        <code class="language-ruby">Yoshi: Medium</code>
        <code class="language-ruby">Bowser: Large</code>
        <code class="language-ruby">Peach: Medium</code>
        <code class="language-ruby">Toad: Small</code>
        
        <p class="blog-text">The <em>Emumerate#each</em> method iterates through, get this, each
        of the elements of the Array and what-ever code you put inside the block will be executed
        once for every element with the current element available for use thorugh the variables inside 
        the pipes, <em>| |</em>.</p>
        
        <h3 class="blog-header">How About One to Inpress Your Friends?</h3>
        <p class="blog-text">Now, we're going to go over an Enumerator that you may never use, but 
        who cares, it's a method. The method is <em>Enumberable#cyle</em> and here is its <a href="#">
        method signature:</a></p>
        <code class="language-ruby">cycle(n=nil) { |obj| block } → nil</code>
        <code class="language-ruby">cycle(n=nil) → an_enumerator</code>
        <p class="blog-text">The signatures is saying the method takes a parameter which is nil by default
        then inside the block is making available the current element of the Array or Hash and execute 
        the code put inside the block. The method will do this however many times you specified as the
        parameter, if you give no parameter it will cycle for inifinity, where as if you 
        put 3, it will cycle three times. Let's do something fun with this; let's make a beat machine:</p>
        <p class="blog-text">First lets build the beat based of a Beastie Boys lyric, hover over quote to hear clip</p>
                <audio id="sound2" src="../audio/beastie_boys_audio.m4a" preload="auto"></audio><a class="" onmouseover="document.getElementById('sound2').play();"><dl>
          <dt><NAME> -</dt>
          <dd>"I got kicks on the one, seven, and eleven. Snares on the five and thirteen!"</dd>
        </dl></a>
        
         <code class="language-ruby">beat_machine = {:one => ['Hi-hat','Bass'], :two => [], :three => ['Hi-hat'],
         :four => [], :five => ['Hi-hat','Snare'], :six => [], :seven => ['Hi-hat','Bass'],
         :eight => [], :nine => ['Hi-hat','Bass'], :ten => [], :eleven => ['Hi-hat','Bass'],
         :twelve => [], :thirteen => ['Hi-hat','Snare'], :fourteen => [], :fiveteen => ['Hi-hat'],
         :sixteen => ['Hi-hat','Bass'],}</code>
         <p class="blog-text">Now Lets use Enumerable#cycle to infinity cycle through all the beats of the measure...</p>
        <pre><code class="language-ruby">beat_machine.cycle() do |beat, instrs|
    puts "#{beat}: #{instrs}"
    sleep(0.3)
end</code></pre>
        <p class="blog-text">Output:</p>
        <code class="language-ruby">one: ["Hi-hat", "Bass"]</code>
        <code class="language-ruby">two: []</code>
        <code class="language-ruby">three: ["Hi-hat"]</code>
        <code class="language-ruby">four: []</code>
        <code class="language-ruby">five: ["Hi-hat", "Snare"]</code>
        <code class="language-ruby">six: []</code>
        <code class="language-ruby">seven: ["Hi-hat", "Bass"]</code>
        <code class="language-ruby">eight: []</code>
        <code class="language-ruby">nine: ["Hi-hat"]</code>
        <code class="language-ruby">ten: []</code>
        <code class="language-ruby">eleven: ["Hi-hat", "Bass"]</code>
        <code class="language-ruby">twelve: []</code>
        <code class="language-ruby">thirteen: ["Hi-hat", "Snare"]</code>
        <code class="language-ruby">fourteen: []</code>
        <code class="language-ruby">fiveteen: ["Hi-hat"]</code>
        <code class="language-ruby">sixteen: []</code>
        <code class="language-ruby">one: ["Hi-hat", "Bass"]</code>
        <code class="language-ruby"># and on and on and on and.....</code>
      <p class="blog-text">Here is how the beat looks on a drum machine. Click on the drum-machine to hear the beat</p>
        <audio id="sound1" src="../audio/drum_machine_audio.m4a" preload="auto"></audio><a class="" onclick="document.getElementById('sound1').play();"><img src="../imgs/drum_machine_beat.png" alt="Sick beat!!!"></a>
        
        <h3 class="blog-header"></h3>

 
 

        <dl>
          <dt>Things That We Learned:</dt>
          <dd>
            <ul class="blog-list">
              <li>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sunt, voluptatum?</li>
              <li>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</li>
              <li>Lorem ipsum dolor sit amet.</li><commit_msg>Modifiy Enum blog<commit_after><!DOCTYPE html>
<html>
  <head>
    <title><NAME></title>
    <meta charset="utf-8">
    <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" /> 
    <link rel="stylesheet" href="../stylesheets/default.css">
    <link rel="stylesheet" href="../stylesheets/blog.css">
    <link href="../stylesheets/prism.css" rel="stylesheet" />
  </head>
  <body>
    <header class="header-wrap">      
      <h1 class="name-logo"><a class="nav-link top-nav-link" href="../index.html"><NAME></a></h1>
      <nav class="top-nav">
        <ul class="nav-list">
          <li class="nav-item"><a class="nav-link top-nav-link" href="../portfolio/portfolio.html">Portfolio</a></li>
          <li class="nav-item"><a class="nav-link top-nav-link current-page" href="blog-index.html">Blog</a></li>
        </ul>
      </nav>      
      <section class="intro-greeting">          
        <h2 class="current-page page-header">Don't Hate, Enumberate</h2>
        <h3 class="sub-title">LETS GET SOME POWER-UPS</h3>
        <h4>xx/xx/xxxx</h4>
        <nav class="arrow-nav intro-greeting-last">
          <ul class="nav-list">
            <li class="nav-item"><a class="nav-link top-nav-link" href="arrays-hashes.html" title="prev blog">&#9664;</a></li>
            <li class="nav-item"><a class="nav-link top-nav-link" href="blog-index.html" title="back">&#9650;</a></li>              
            <li class="nav-item"><a class="nav-link top-nav-link" href="git.html" title="next blog">&#9658;</a></li>              
          </ul>            
        </nav>
      </section>
    </header>
    <div class="text-width">
      <article class="main-content">
        <figure>
          <img src="../imgs/beasty_boys.jpg" alt="Num Num Arrays are Yummy">
          <figcaption>What do you mean you forgot the fish-eye lens?...</figcaption>
        </figure>              
        
        <h3 class="blog-header">Enumerables Everyone!</h3>
        <p class="blog-text">Enermable is a <em>mixin</em> that allows collection classes,
        like Arrays and Hashes, the ability to easily traverse, search and sort within themselfs 
        through the use of the mixins methods.</p>
        <h3 class="blog-header">Whats a mixin?</h3>
        <p class="blog-text">Mixins are <em><a href="http://ruby-doc.com/docs/ProgrammingRuby/html/tut_modules.html" target="_blank">Modules</a></em> that are "mixed into" a class, giving that Class access to the Modules methods. Mixins are like a power upgrades in Mario; You can give your Array fire-power, and give your Hashes Yoshi! Mixins allow for a class to inherit functionality from multiple sources; this is good becuase Ruby only allows
        <em>single inheritance</em>; mixins are a sort-of work around that.</p>

        <h3 class="blog-header">Back To Enumerables</h3>
        <p class="blog-text">Enumerable offers many <em>very</em> useful <a href="http://ruby-doc.org/core-2.2.3/Enumerable.html" target="_blank">methods</a>
        These methods have differant iterations for Arrays and Hashes. Like here is the Enumerable#each method being used 
        with an Array then with a Hash:</p>
        <code class="language-ruby">mario_characters = [Mario, Yoshi, Bowser, Peach, Toad]</code>
         <code class="language-ruby">character_size = { Mario: 'Medium', Yoshi: 'Medium', Bowser: 'Large',
         Peach: 'Medium', Toad: 'Small'}</code>
        <code class="language-ruby">mario_characters.each { |char| puts char}</code>
        <code class="language-ruby">Mario</code>
        <code class="language-ruby">Yoshi</code>
        <code class="language-ruby">Bowser</code>
        <code class="language-ruby">Peach</code>
        <code class="language-ruby">Toad</code>
        <code class="language-ruby"> </code>
        <code class="language-ruby">character_size.each { |char, size| puts "#{char}: #{size}"}</code>
        <code class="language-ruby">Mario: Medium</code>
        <code class="language-ruby">Yoshi: Medium</code>
        <code class="language-ruby">Bowser: Large</code>
        <code class="language-ruby">Peach: Medium</code>
        <code class="language-ruby">Toad: Small</code>
        
        <p class="blog-text">The <em>Enumerable#each</em> method iterates through each
        of the elements of the Array/Hash and what-ever code you put inside the block will be executed
        once for every element with the current element available for use thorugh the variables inside 
        the pipes: <em>| |</em>.</p>
        
        <h3 class="blog-header">How About One to Inpress Your Friends?</h3>
        <p class="blog-text">Now, we're going to go over an Enumerable that you may never use, but 
        who cares, it's a method. The method is <em>Enumerable#cyle</em> and here is its <a href="#">
        method signature:</a></p>
        <code class="language-ruby">cycle(n=nil) { |obj| block } → nil</code>
        <code class="language-ruby">cycle(n=nil) → an_enumerator</code>
        <p class="blog-text">The signatures is saying the method takes a parameter which is nil by default
        then inside the block is making available the current element of the Array or Hash and executing 
        the code put inside the block. The method will do this however many times you specified as the
        parameter, if you give no parameter it will cycle for inifinity, where as if you 
        put 3, it will cycle three times. Let's do something fun with this; let's make a drum-machine:</p>
        <audio id="sound2" src="../audio/beastie_boys_audio.m4a" preload="auto"></audio>
        <p class="blog-text">First lets build the beat based of a Beastie Boys lyric, <em onclick="document.getElementById('sound2').play();">Click here to hear audio-clip</em></p>
        <dl>
          <dt><NAME> -</dt>
          <dd>"I got kicks on the one, seven, and eleven. Snares on the five and thirteen!"</dd>
        </dl>
        
         <code class="language-ruby">drum_machine = {:one => ['Hi-hat','Kick'], :two => [], :three => ['Hi-hat'],
         :four => [], :five => ['Hi-hat','Snare'], :six => [], :seven => ['Hi-hat','Kick'],
         :eight => [], :nine => ['Hi-hat','Kick'], :ten => [], :eleven => ['Hi-hat','Kick'],
         :twelve => [], :thirteen => ['Hi-hat','Snare'], :fourteen => [], :fiveteen => ['Hi-hat'],
         :sixteen => []}</code>
         <p class="blog-text">Now Lets use Enumerable#cycle to infinitely cycle through all the beats of the measure...</p>
        <pre><code class="language-ruby">drum_machine.cycle() do |beat, instrs|
    puts "#{beat}: #{instrs}"
    sleep(0.3)
end</code></pre>
        <p class="blog-text">Output:</p>
        <code class="language-ruby">one: ["Hi-hat", "Kick"]</code>
        <code class="language-ruby">two: []</code>
        <code class="language-ruby">three: ["Hi-hat"]</code>
        <code class="language-ruby">four: []</code>
        <code class="language-ruby">five: ["Hi-hat", "Snare"]</code>
        <code class="language-ruby">six: []</code>
        <code class="language-ruby">seven: ["Hi-hat", "Kick"]</code>
        <code class="language-ruby">eight: []</code>
        <code class="language-ruby">nine: ["Hi-hat"]</code>
        <code class="language-ruby">ten: []</code>
        <code class="language-ruby">eleven: ["Hi-hat", "Kick"]</code>
        <code class="language-ruby">twelve: []</code>
        <code class="language-ruby">thirteen: ["Hi-hat", "Snare"]</code>
        <code class="language-ruby">fourteen: []</code>
        <code class="language-ruby">fiveteen: ["Hi-hat"]</code>
        <code class="language-ruby">sixteen: []</code>
        <code class="language-ruby">one: ["Hi-hat", "Kick"]</code>
        <code class="language-ruby"># and on and on and on and.....</code>
        <p class="blog-text">Here is how the beat looks on a drum machine. <em>Click on the drum-machine to hear the beat</em></p>
        <audio id="sound1" src="../audio/drum_machine_audio.m4a" preload="auto"></audio>
        <a class="" onclick="document.getElementById('sound1').play();">
          <img src="../imgs/drum_machine_beat.png" alt="Sick beat!!!">
        </a>        
        <h3 class="blog-header">Did We Just Learn About Drum Machines or Enumerables?</h3>
        <dl>
          <dt>Things That We Learned:</dt>
          <dd>
            <ul class="blog-list">
              <li>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sunt, voluptatum?</li>
              <li>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</li>
              <li>Lorem ipsum dolor sit amet.</li>
{'fraction_non_alphanumeric': 0.17407146215326752, 'fraction_numerical': 0.005054066760695816, 'mean_word_length': 2.8896, 'pattern_counts': {'":': 0, '<': 437, '<?xml version=': 0, '>': 469, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4123424', 'n_tokens_mistral': 5450, 'n_tokens_neox': 5257, 'n_words': 1428}