March 3, 2015 by Daniel P. Clark

Ruby: The Case for Case

It’s nice to have case and when available in Ruby.  But I don’t see it used too often.  I myself don’t use it much because I’m more accustomed to just using if and else.  So let’s get into case switching. person = “employee” case person when “boss” puts “Yes sir!” when “employee” puts “Sure I’ll…

Continue Reading »

March 1, 2015 by Daniel P. Clark

Version Both Your Github Repo and Gem

There are many howtos on getting started with Github and creating a Ruby gem.  What I haven’t come across is a blog about versioning your github releases.  So I will demonstrate here the steps I go through after verifying a gem is ready, releasing it, and publishing a version to the code base on Github….

Continue Reading »

February 27, 2015 by Daniel P. Clark

Value Assignment and Deferment with Lambdas/Procs

When assigning a variable with a raw value the outcome is as you would expect. greeting = “hello” # => “hello” puts greeting # hello Now while learning about assigning methods to variables I used to wonder if I was assigning the result value from the method, or simply pointing to the method to be…

Continue Reading »

February 24, 2015 by Daniel P. Clark

Writing methods for both class and instance levels

When perusing the Rails documentation for various methods I noticed something that seemed odd to me.  The method descriptions seemed to show an extra parameter as the first parameter that I was never using.  It’s strange when you use the methods all the time and it doesn’t seem to be implemented the way the documentation…

Continue Reading »

February 21, 2015 by Daniel P. Clark

Minitest with Watir-webdriver

Why, you might ask, would I even think of Watir-webdriver?  Well let me tell you.  It’s because it’s easy and fun.  It’s not a fast way to run tests though.  What Watir will do for you is open an actual web browser window and let you check and interact with it from your Ruby code….

Continue Reading »

February 20, 2015 by Daniel P. Clark

Some Basic Ruby Tools for Sniffing out Errors

Needing to know what’s going on under the hood is a big part to solving problems and challenges.  For the longest time I only ever used print statements to output to the console the state of something at a specific point.  That’s all I ever used in Python.  But sometimes you need to do a…

Continue Reading »

February 14, 2015 by Daniel P. Clark

Use the given project generators

Rails Before I started using Rails I was the guy who would type out web projects by hand… I was accustomed to it.  I knew what I was working with all the time simply because I wrote it.  When I had started reading the docs on Rails I was trying to learn it in this…

Continue Reading »

February 4, 2015 by Daniel P. Clark

Using Ruby Object Type Classes to Safely Build Data

When building collections of data you will find situations where the types aren’t what you planned to work with.  And when I say types I’m speaking generically of arrays, hashes, strings, integers, nil, etc.  Everything’s cosy when you know what your getting.  For example putting 10 integers into an Array: arr = [] 10.times do…

Continue Reading »

January 27, 2015 by Daniel P. Clark

or

Truthiness Both or and || will return the first item that evaluates as true from the left side to the right. true or “this doesn’t return” # => true true || “this doesn’t return” # => true false || true # => true false || false # => false false or false or 1 or…

Continue Reading »

January 20, 2015 by Daniel P. Clark

Refinements over Monkey-patching

Monkey patching is rather straight forward.  You take an existing object and you apply your own duct tape, glue, nuts and bolts, or even chewing gum.  Or if it’s bad you hit it with a hammer.  No, but more seriously, it’s when you modify something existing from outside it’s original project code. For example you…

Continue Reading »

Page 3 of 4
1 2 3 4
1 2 3 4