Skip to content

Instantly share code, notes, and snippets.

@fj fj/Gemfile
Last active May 5, 2018

Embed
What would you like to do?
a pairing interview for Recurse
require_relative "./printer"
class BinaryPrinter < Printer
def render
raise NotImplementedError
end
end
#! /usr/bin/env ruby
require "paint"
require "datetime"
require_relative "./text_printer"
class Clock
attr_reader :time
def initialize(time_string)
@time = DateTime.parse(time_string)
end
def to_s
time.strftime("%H:%M:%S")
end
end
clock = Clock.new(Time.now)
TextPrinter.new(clock.to_s).draw
BinaryPrinter.new(clock.to_s).draw
source "https://rubygems.org"
ruby "2.5.0"
gem "paint"
class Printer
attr_reader :text
def initialize(text)
@text = text
end
def draw
puts render
end
end
require_relative './printer'
class TextPrinter < Printer
def render
raise NotImplementedError
end
def digits
@digits ||= {
"0": %w(
.xxx.
x...x
x...x
x...x
.xxx.
),
"1": %w(
xxx..
..x..
..x..
..x..
xxxxx
),
"2": %w(
.xxx.
x...x
..xx.
.x...
xxxxx
),
"3": %w(
xxxx.
....x
xxxx.
....x
xxxx.
),
"4": %w(
x..x.
x..x.
xxxxx
...x.
...x.
),
"5": %w(
xxxxx
x....
xxxx.
....x
xxxx.
),
"6": %w(
.xxx.
x....
xxxx.
x...x
.xxx.
),
"7": %w(
xxxxx
....x
...x.
..x..
.x...
),
"8": %w(
.xxx.
x...x
.xxx.
x...x
.xxx.
),
"9": %w(
.xxx.
x...x
.xxxx
....x
.xxx.
)
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.