<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Ruby Reference on developwith — developer tips</title>
    <link>https://developwith.com/tags/ruby-reference/</link>
    <description>Recent content in Ruby Reference on developwith — developer tips</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <atom:link href="https://developwith.com/tags/ruby-reference/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Basics</title>
      <link>https://developwith.com/languages/ruby/basics/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://developwith.com/languages/ruby/basics/</guid>
      <description>&lt;p&gt;Ruby&amp;rsquo;s programming style consists of snake case for variable and method naming. Classes and modules follow a camel case style. Ruby allows for organization of your application into modules, classes or straight functional programming approaches. Semicolon and parenthesis are optional in the calling of methods and most of the time not added. The typing system within Ruby is called &lt;code&gt;Duck Typing&lt;/code&gt;. It means that any object could act as another object without the need of extending or implementing a common ancestor. If they both look alike (ie. methods, etc&amp;hellip;) they can be used the same.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Bundler</title>
      <link>https://developwith.com/languages/ruby/libraries/bundler/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://developwith.com/languages/ruby/libraries/bundler/</guid>
      <description>&lt;h2 id=&#34;overview&#34;&gt;Overview&lt;/h2&gt;&#xA;&lt;p&gt;Most applications you&amp;rsquo;ll see written in ruby take advantage of the functionality in the &lt;a href=&#34;http://bundler.io/&#34;&gt;Bundler&lt;/a&gt;. The Bundler provides a way to create a &lt;code&gt;Gemfile&lt;/code&gt; that lists all your dependencies and will install them for you by running &lt;code&gt;gem install&lt;/code&gt; in your application directory. It is a very convenient way to work on a Ruby project with a team.  When &lt;code&gt;gem install&lt;/code&gt; is run it will create a &lt;code&gt;Gemfile.lock&lt;/code&gt; file which indicates what the last set of gems install as part of the project. This is typically checked into the version control with the Gemfile.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Classes and Modules</title>
      <link>https://developwith.com/languages/ruby/class-and-modules/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://developwith.com/languages/ruby/class-and-modules/</guid>
      <description>&lt;h1 id=&#34;classes-and-modules&#34;&gt;Classes and Modules&lt;/h1&gt;&#xA;&lt;p&gt;Ruby provides a couple ways to organize your application. You can put methods and variables into a Class, or you can create methods in a module that can be included in classes. Modules are similar to packages in other languages except that they can be added to classes as a type of mixin to provide extra functionality at runtime.&lt;/p&gt;&#xA;&lt;h2 id=&#34;class&#34;&gt;Class&lt;/h2&gt;&#xA;&lt;p&gt;A class is an instantiable unit that can contain variables and methods for interacting with data. Most of the time a class represents a part of your business model, a controller for request processing or business feature. In a class you can define attribute accessors which streamline the get / set and variable definitions for you.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Collections and Loops</title>
      <link>https://developwith.com/languages/ruby/collections-and-loops/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://developwith.com/languages/ruby/collections-and-loops/</guid>
      <description>&lt;h1 id=&#34;collection-and-loops&#34;&gt;Collection and Loops&lt;/h1&gt;&#xA;&lt;p&gt;Ruby has many default collection types that provide quite a bit of functionality to get you started. There is some shorthand and longhand techniques for iterating over collections that make it easier to have cleaner code.&lt;/p&gt;&#xA;&lt;h2 id=&#34;collections&#34;&gt;Collections&lt;/h2&gt;&#xA;&lt;p&gt;The main collections in Ruby are &lt;code&gt;Arrays&lt;/code&gt; and Maps/&lt;code&gt;Hashes&lt;/code&gt;. &lt;code&gt;Arrays&lt;/code&gt; are used for linear ordered lists, while &lt;code&gt;Hashes&lt;/code&gt; are used name / value pairs and are unordered by nature. Both have similar named iteration methods that make using either very convenient. Both have a long and short way of creating the initial collection as well.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Conditions</title>
      <link>https://developwith.com/languages/ruby/conditions-and-switches/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://developwith.com/languages/ruby/conditions-and-switches/</guid>
      <description>&lt;p&gt;#Conditions and Switches#&#xA;In Ruby, there are various ways to create conditions, use them and write logic. Ruby also provides switch statements in the form of cases that help to simplify logic from time to time.&lt;/p&gt;&#xA;&lt;p&gt;#Conditions#&lt;/p&gt;&#xA;&lt;p&gt;Conditions are basically &lt;code&gt;if&lt;/code&gt;, &lt;code&gt;elsif&lt;/code&gt; and &lt;code&gt;else&lt;/code&gt; branching within Ruby. Where it takes a shift from other languages is the convient shorthand approaches to the way to set empty variables and returning the values of an inline conditional statement. Like most languages Ruby also includes a ternary operator.&lt;/p&gt;</description>
    </item>
    <item>
      <title>List of libraries for Ruby</title>
      <link>https://developwith.com/languages/ruby/libraries/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://developwith.com/languages/ruby/libraries/</guid>
      <description></description>
    </item>
    <item>
      <title>Nokogiri</title>
      <link>https://developwith.com/languages/ruby/libraries/nokogiri/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://developwith.com/languages/ruby/libraries/nokogiri/</guid>
      <description>&lt;h2 id=&#34;overview&#34;&gt;Overview&lt;/h2&gt;&#xA;&lt;p&gt;&lt;a href=&#34;http://nokogiri.org/?utm_source=developwith.com&#34;&gt;Nokogiri&lt;/a&gt; is an HTML, XML, SAX, and Reader parser. Among Nokogiri’s many features is the ability to search documents via XPath or CSS3 selectors.&lt;/p&gt;&#xA;&lt;h2 id=&#34;setup&#34;&gt;Setup&lt;/h2&gt;&#xA;&lt;p&gt;To install run &lt;code&gt;gem install nokogiri&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h2 id=&#34;source&#34;&gt;Source&lt;/h2&gt;&#xA;&lt;p&gt;Source is found at &lt;a href=&#34;http://github.com/sparklemotion/nokogiri&#34;&gt;github.com/sparklemotion/nokogiri&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Puma</title>
      <link>https://developwith.com/languages/ruby/libraries/puma/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://developwith.com/languages/ruby/libraries/puma/</guid>
      <description>&lt;h2 id=&#34;overview&#34;&gt;Overview&lt;/h2&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://puma.io/&#34;&gt;Puma&lt;/a&gt; is an application web server for Ruby that supports multi-threading and multi-processing. It&amp;rsquo;s the default server for Rails and excels at handling many concurrent connections with modest memory usage.&lt;/p&gt;&#xA;&lt;h2 id=&#34;setup&#34;&gt;Setup&lt;/h2&gt;&#xA;&lt;p&gt;To install run &lt;code&gt;gem install puma&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Or add it to your Gemfile:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-ruby&#34; data-lang=&#34;ruby&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# Gemfile&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;gem&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;puma&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;starting-puma&#34;&gt;Starting Puma&lt;/h2&gt;&#xA;&lt;p&gt;Start Puma from the command line:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# Start with defaults (0.0.0.0:9293)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;puma&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# Specify host and port&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;puma -b tcp://0.0.0.0:3000&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# Run in the background&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;puma -d&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#xA;&lt;p&gt;For Rails applications, Puma is started via:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Rake</title>
      <link>https://developwith.com/languages/ruby/libraries/rake/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://developwith.com/languages/ruby/libraries/rake/</guid>
      <description>&lt;h2 id=&#34;overview&#34;&gt;Overview&lt;/h2&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://ruby.github.io/rake/&#34;&gt;Rake&lt;/a&gt; is a task runner for Ruby — think of it as Ruby&amp;rsquo;s answer to &lt;code&gt;make&lt;/code&gt;. It lets you define tasks with dependencies and run them from the command line. Rake is the standard way to automate repetitive jobs in Ruby projects, from running tests to generating documentation.&lt;/p&gt;&#xA;&lt;h2 id=&#34;setup&#34;&gt;Setup&lt;/h2&gt;&#xA;&lt;p&gt;To install run &lt;code&gt;gem install rake&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Most Ruby projects include Rake by default via the Gemfile:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-ruby&#34; data-lang=&#34;ruby&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# Gemfile&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;gem&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;rake&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;defining-tasks&#34;&gt;Defining Tasks&lt;/h2&gt;&#xA;&lt;p&gt;Create a file named &lt;code&gt;Rakefile&lt;/code&gt; in your project root:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Ruby</title>
      <link>https://developwith.com/references/ruby/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://developwith.com/references/ruby/</guid>
      <description></description>
    </item>
    <item>
      <title>Slice and Ranges</title>
      <link>https://developwith.com/references/ruby/slice/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://developwith.com/references/ruby/slice/</guid>
      <description>&lt;p&gt;Slicing is a way to get a subset of elements from an array or string. A string is a fancy array of characters.&lt;/p&gt;&#xA;&lt;p&gt;To get a subset of elements in an array in ruby, use the range operator &lt;code&gt;..&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Example:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-ruby&#34; data-lang=&#34;ruby&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;word_numbers&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;one&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;two&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;three&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;four&amp;#39;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;skip_first_number_list&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;word_numbers&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;..-&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#xA;&lt;p&gt;Using &lt;code&gt;-1&lt;/code&gt; will get all the values until the end of the array. Since array indexes start with &lt;code&gt;0&lt;/code&gt;, using &lt;code&gt;1&lt;/code&gt; in the above example skips the first element and returns the rest of the elements.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Split</title>
      <link>https://developwith.com/references/ruby/split/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://developwith.com/references/ruby/split/</guid>
      <description>&lt;p&gt;Splitting is a way to separate a string based on a delimiter. A delimiter is the part of the string that marks how the string is structured. The default delimiter in ruby&amp;rsquo;s &lt;code&gt;split&lt;/code&gt; method is a space.&lt;/p&gt;&#xA;&lt;p&gt;For instance, in a comma delimited list (CSV), the string is divided into values based on a comma. If you wanted to split the string in ruby on the comma you would use a &lt;code&gt;split&lt;/code&gt; method.&lt;/p&gt;</description>
    </item>
    <item>
      <title>String Manipulation</title>
      <link>https://developwith.com/languages/ruby/string-manipulation/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://developwith.com/languages/ruby/string-manipulation/</guid>
      <description>&lt;p&gt;#String Manipulation#&lt;/p&gt;&#xA;&lt;h2 id=&#34;strip-a-string&#34;&gt;Strip a string&lt;/h2&gt;&#xA;&lt;p&gt;To trim the whitespace off a string you can run the following:&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-ruby&#34; data-lang=&#34;ruby&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;my_string&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34; oh boy &amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# To trim into another variable&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;my_trimmed_string&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;my_string&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;strip&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# To trim in place&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;my_string&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;strip!&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;&#xA;&lt;p class=&#34;next&#34;&gt;&lt;strong&gt;Next:&lt;/strong&gt; &lt;a href=&#34;https://developwith.com/languages/ruby/class-and-modules/&#34;&gt;Classes and Modules&lt;/a&gt; &lt;/p&gt;</description>
    </item>
  </channel>
</rss>
