<?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/categories/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/categories/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>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>Getting Started with Ruby</title>
      <link>https://developwith.com/languages/ruby/getting-started/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://developwith.com/languages/ruby/getting-started/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://www.ruby-lang.org&#34;&gt;Ruby&lt;/a&gt; is a runtime language which means it does not have to be precompiled like Java, C, or Go. Ruby requires a virtual machine (VM) to run the language. You can use either Jruby (JVM based runtime) or the default Ruby VM. The majority of usage for ruby is for web applications using &lt;a href=&#34;http://rubyonrails.org/&#34;&gt;Rails&lt;/a&gt; or &lt;a href=&#34;http://www.sinatrarb.com/&#34;&gt;Sinatra&lt;/a&gt;. Although the devops community has adopted it extensively for configuration and provisioning in &lt;a href=&#34;http://puppetlabs.com/&#34;&gt;Puppet&lt;/a&gt; and &lt;a href=&#34;http://www.opscode.com/chef/&#34;&gt;Chef&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;h2 id=&#34;setup&#34;&gt;Setup&lt;/h2&gt;&#xA;&lt;p&gt;&lt;strong&gt;Install Windows:&lt;/strong&gt;&#xA;Download the &lt;a href=&#34;http://rubyinstaller.org/&#34;&gt;RubyInstaller&lt;/a&gt; and follow the instructions.&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 Language</title>
      <link>https://developwith.com/languages/ruby/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://developwith.com/languages/ruby/</guid>
      <description>&lt;p&gt;Ruby is a dynamic, object-oriented language known for developer happiness. It powers Rails, Sinatra, and much of the devops toolchain (Puppet, Chef, Capistrano).&lt;/p&gt;&#xA;&lt;h2 id=&#34;learning-path&#34;&gt;Learning Path&lt;/h2&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;https://developwith.com/languages/ruby/getting-started/&#34;&gt;Getting Started&lt;/a&gt;&lt;/strong&gt; — Install, RVM, Bundler&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;https://developwith.com/languages/ruby/basics/&#34;&gt;Basics&lt;/a&gt;&lt;/strong&gt; — Variables, methods, blocks&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;https://developwith.com/languages/ruby/conditions-and-switches/&#34;&gt;Conditions &amp;amp; Switches&lt;/a&gt;&lt;/strong&gt; — if/elsif/else, case&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;https://developwith.com/languages/ruby/collections-and-loops/&#34;&gt;Collections &amp;amp; Loops&lt;/a&gt;&lt;/strong&gt; — Arrays, Hashes, each, map&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;https://developwith.com/languages/ruby/string-manipulation/&#34;&gt;String Manipulation&lt;/a&gt;&lt;/strong&gt; — strip, interpolation, regex&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;https://developwith.com/languages/ruby/class-and-modules/&#34;&gt;Classes &amp;amp; Modules&lt;/a&gt;&lt;/strong&gt; — OOP, mixins, namespaces&lt;/li&gt;&#xA;&lt;/ol&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/getting-started/&#34;&gt;Getting Started&lt;/a&gt;&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>
