[2016][ruby][18.0] Row#initialize

profile
Alpha Chen 8 years ago
parent 56ee9d38ac
commit ba95efbf88

@ -0,0 +1,18 @@
class Row
INPUT_MAP = { ?. => :safe, ?^ => :trap }
attr_reader :tiles
def initialize(input)
@tiles = input.chars.map {|char| INPUT_MAP.fetch(char) }
end
end
require 'minitest/autorun'
class TestRow < Minitest::Test
def test_row
row = Row.new('..^^.')
assert_equal %i[ safe safe trap trap safe ], row.tiles
end
end
Loading…
Cancel
Save