<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ashley</title>
    <description>The latest articles on DEV Community by Ashley (@saturn226).</description>
    <link>https://dev.to/saturn226</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F71568%2F6d0a4399-082b-48b5-a0c7-c80af6743add.jpeg</url>
      <title>DEV Community: Ashley</title>
      <link>https://dev.to/saturn226</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/saturn226"/>
    <language>en</language>
    <item>
      <title>Ruby Self</title>
      <dc:creator>Ashley</dc:creator>
      <pubDate>Mon, 09 Aug 2021 02:13:47 +0000</pubDate>
      <link>https://dev.to/saturn226/ruby-self-5gkd</link>
      <guid>https://dev.to/saturn226/ruby-self-5gkd</guid>
      <description>&lt;p&gt;The keyword &lt;code&gt;self&lt;/code&gt; in ruby gives you access to the current object&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Class&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the context of a class &lt;code&gt;self&lt;/code&gt; refers to the current class&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Dog&lt;/span&gt;
  &lt;span class="nb"&gt;p&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt; &lt;span class="c1"&gt;# the Dog class&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Defining a method on self creates a class method&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Instance Method&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Within an instance method self refers to the instance itself&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Dog&lt;/span&gt;
  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;bark&lt;/span&gt;
    &lt;span class="nb"&gt;self&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="nb"&gt;p&lt;/span&gt; &lt;span class="no"&gt;Dog&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bark&lt;/span&gt; &lt;span class="c1"&gt;# an instance of the Dog class&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Implicit Self&lt;/strong&gt;&lt;br&gt;
When you call a method without an explicit recieving object, the method is called implicitely on self. In plain english this means that if there is nothing on the left hand side of the function call then the left hand side is self.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Person&lt;/span&gt;
  &lt;span class="nb"&gt;attr_reader&lt;/span&gt; &lt;span class="ss"&gt;:first_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:last_name&lt;/span&gt;

  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;initialize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;first_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;last_name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="vi"&gt;@first_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;first_name&lt;/span&gt;
    &lt;span class="vi"&gt;@last_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;last_name&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;

  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;full_name&lt;/span&gt;
    &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;first_name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;last_name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="c1"&gt;#implied self. Instance of person&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Top Level&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;At the top level self refers to the main ruby object&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="nb"&gt;p&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt; &lt;span class="c1"&gt;# the main object&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Modules&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When self is used &lt;strong&gt;within an instance method of a module&lt;/strong&gt; it refers to the &lt;strong&gt;instance of the class in which the module is included&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you see self &lt;strong&gt;outside of an instance method inside a module&lt;/strong&gt; it &lt;strong&gt;refers to the module&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you were wondering what &lt;code&gt;p&lt;/code&gt; by itself is. Its a kernel method that behaves similar to obj.inspect. Try calling it on some objects :)&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Fun Ruby tricks I learned in codewars</title>
      <dc:creator>Ashley</dc:creator>
      <pubDate>Mon, 09 Aug 2021 02:08:44 +0000</pubDate>
      <link>https://dev.to/saturn226/fun-ruby-tricks-i-learned-in-codewars-41nl</link>
      <guid>https://dev.to/saturn226/fun-ruby-tricks-i-learned-in-codewars-41nl</guid>
      <description>&lt;p&gt;I have been playing around with codewars a lot lately. (&lt;a href="http://www.codewars.com"&gt;www.codewars.com&lt;/a&gt;) I like working with code challenges they are pretty fun. One thing that is great about playing with codewars is that I got to use a lot of tools and methods I would have never else thought of for example&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;delete&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This comes in handy for challenges that ask you to remove a series of elements from a string.&lt;br&gt;
For example, if you need to remove some vowels from a string&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt; &lt;span class="n"&gt;my_string&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"This is such a wonderful method"&lt;/span&gt;
 &lt;span class="n"&gt;my_string&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"aeiou"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 

 &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="no"&gt;Ths&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="n"&gt;sch&lt;/span&gt;  &lt;span class="n"&gt;wndrfl&lt;/span&gt; &lt;span class="n"&gt;mthd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is much easier than using gsub!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;to_str(base)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So most everyone knows how to_s works, you are converting a non string object to a string representation of that object. But one thing a lot of people forget is that you can pass in an argument to to_s when its placed on a Fixnum. This argument represents a numerical base which by default is 10. Therefore, this method can be used to convert numbers to different bases&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;  &lt;span class="mi"&gt;35&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to_s&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"100011"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;partition&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is a great way to split up some data. It accepts a block and creates 2 arrays. For the elements that are true, they are first array, while the rest are placed in the second array.  Imagine we have a problem where we need to seperate some evens and odds&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;  &lt;span class="n"&gt;my_array&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;my_array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;partition&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;even?&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;even? odd?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Which reminds me, I have a tendency to forget about these ruby methods. They work just as you expect. The question mark signify's this method returns some sort of boolean.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;  &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;even?&lt;/span&gt;
  &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kp"&gt;true&lt;/span&gt;

    &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;odd?&lt;/span&gt;
    &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kp"&gt;false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Its a shame how often I resort to modulo to check for evens and odds knowing this exists&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;chars&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;chars will split a string into an array of chars&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt; &lt;span class="s2"&gt;"This is my string"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;chars&lt;/span&gt;
 &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"T"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"h"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"i"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"s"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"i"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"s"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"m"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"y"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"s"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"t"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"r"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"i"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"n"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"g"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;of course split('') would do the same, but I like this better&lt;/p&gt;

&lt;p&gt;Code challenges are super fun, and its great to learn new tricks. I recomment trying codwars sometime or even hacker rank or leetcode. I think Im going to go do some SQL challenges now!&lt;/p&gt;

</description>
      <category>codewars</category>
      <category>ruby</category>
      <category>fun</category>
    </item>
    <item>
      <title>Hello World</title>
      <dc:creator>Ashley</dc:creator>
      <pubDate>Sat, 31 Jul 2021 21:09:54 +0000</pubDate>
      <link>https://dev.to/saturn226/hello-world-4e97</link>
      <guid>https://dev.to/saturn226/hello-world-4e97</guid>
      <description>&lt;p&gt;So I am currently in the process of trying to get my portfolio website deployed. Boy oh boy, has this process been a lot more difficult than I thought. I have decided to use React with styled-components to get more comfortable with doing more frontend work. Last time I tried messing with React it was a pretty rough experience. Well, I suppose React wasn't the issue but I could not for whatever reason get my hands around Redux. The library was so small and in theory it made so much sense to me but then every single time I tried to implement state into my program, I was never able to walk through my program logic. But now I have discovered React Hooks and oh my gosh, I ADORE React Hooks. The context API and useEffect are fantastic. Welp, I hope to add more blog posts in the future. &lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
