Last active
December 5, 2021 05:48
-
-
Save stephancom/ab70dac4722926462470ecc4c03b34ad to your computer and use it in GitHub Desktop.
a software poem for john langfeld
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/ruby | |
pearls = <<~ENDOFPOEM.freeze | |
Framed, Mounted and Preggers' | |
22975 | |
6/19/19 | |
Sneaking out of the bedroom in the wee hours he sat, | |
staring at digits and images and flummox and hope. | |
Who stared back? | |
01010100 01101000 01100101 00100000 | |
01000101 01110110 01101001 01101100 00100000 | |
01010001 01110101 01100101 01100101 01101110 00101110 | |
ENDOFPOEM | |
# how else wouldst thy pearl be cast? | |
class Swine | |
def initialize(name) | |
@name = name | |
end | |
def cast(str) | |
bytes = digest(str) | |
excrete(bytes) | |
end | |
private | |
def digest(str) | |
str.scan(/([01]{8})/).flatten.map { |byte| byte.to_i(2).chr }.join | |
end | |
def excrete(bytes) | |
"#{@name} oinks '#{bytes}'\n#{@name} laughs out loud." | |
end | |
end | |
pig = Swine.new('stephan') | |
puts pig.cast(pearls) |
Author
stephancom
commented
Dec 5, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment