FPOO Chapter 4: Encapsulating methods in the constructor

Today I slightly refine the nascent OO implementation in Elixir. Here’s the new point constructor, with methods contained within it: def new_point(x, y) do [ x: x, y: y, __class_symbol__: :point, __methods__: [ class: &get(&1, :__class_symbol__), shift: fn (this, xinc, … Continue reading

Posted in Elixir | Tagged , | Leave a comment

FPOO Chapters 2 & 3: Basic Objects in Elixir

I feel like I should start with a disclaimer: this post is not advocating building an OO system on top of an FP language. And anyway, the Elixir/Erlang “process” model is arguably a very OO system right out of the … Continue reading

Posted in Elixir | Tagged , | Leave a comment

Watch me build an app (one day sale!)

As I posted a few months ago, the good folks at TekPub recently took my hours of footage of a weekend coding project and turned it into a tightly edited hour-and-fifteen-minute screencast. Well, as you might have heard, TekPub has … Continue reading

Posted in Announcements, Rails, Ruby, Screencasts, Videos | Leave a comment

FPOO Chapter 1 in Elixir

Exercise 3: add-squares First up, we have add-squares. Let’s write a test… test “1.18-3: add-squares” do assert(add_squares([1, 2, 5]) == 30) end My Elixir version takes a list rather than a variable number of arguments, because Erlang doesn’t do the … Continue reading

Posted in Elixir | Tagged , , | 5 Comments

Re-implementing apply in Elixir

Elixir already has a perfectly good apply. But FPOO suggests I try to write my own version, and why not? def my_apply(func, sequence) do code = quote do unquote(func).(unquote_splicing(sequence)) end {result, _} = Code.eval_quoted(code) result end This is considerably more … Continue reading

Posted in Elixir | Tagged , | Leave a comment

The day my gems disappeared

So my Rakefile kept telling me RSpec wasn’t installed. begin require ‘rspec/core/rake_task’ RSpec::Core::RakeTask.new(:spec) task :default => :spec task :spec => :dotenv rescue LoadError warn “RSpec unavailable; spec task not defined” end $ rake spec RSpec unavailable; spec task not defined … Continue reading

Posted in Howto | Tagged | 4 Comments

RubyTapas Freebie – Gem-Love Part 3


Sometimes on RubyTapas I serialize larger projects into bite-sized pieces. In this episode, you can see a slice of the outside-in TDD process I use as I develop part of my gem-love project. You’ll see me thinking about messages before … Continue reading

Posted in Ruby, RubyTapas Samples, Screencasts | Tagged , , , , , | Leave a comment

Sorting Lines in 5 Languages

Implementing a simple scripting task in various languages. Continue reading

Posted in Uncategorized | Tagged , , , , | 17 Comments

RubyTapas Freebie: Enumerator


It’s been a while since I posted a freebie. Today’s is episode 59. It covers one of the most interesting (to me) classes in the Ruby core libraries: Enumerator.

Posted in Ruby, RubyTapas Samples, Screencasts | Tagged , | Leave a comment

Bounded Queue in Ruby

I don’t post code on here nearly as often as I should. Here’s some code I just finished for a future RubyTapas episode. It implements a thread-safe, optionally bounded, timeout-enabled queue class suitable for communication between threads. Please throw rocks … Continue reading

Posted in Ruby | Tagged , , | 2 Comments