Skip to content

Instantly share code, notes, and snippets.

@pdbradley
Created December 1, 2016 00:03
Show Gist options
  • Save pdbradley/f6c67ce56bc2179d9f40eff835e70c60 to your computer and use it in GitHub Desktop.
Save pdbradley/f6c67ce56bc2179d9f40eff835e70c60 to your computer and use it in GitHub Desktop.
blur2.rb
class Image
def initialize(image)
@image = image
end
def output_image
@image.each do |row|
row.each do |cell|
print cell # always puts a newline
end
puts ""
end
end
def blur
end
def image_width
@image.first.size
end
def image_height
@image.size
end
def too_far_right?(col)
col >= image_width
end
end
# image = Image.new([
# [0, 0, 0, 0],
# [0, 1, 0, 0],
# [0, 0, 0, 1],
# [0, 0, 0, 0]
# ])
image = Image.new([
[0, 0, 0, 0, 0],
[0, 1, 0, 0, 0],
[0, 0, 0, 1, 0],
[0, 0, 0, 0, 0]
])
image.output_image
puts "image width is"
puts image.image_width
puts "image height is"
puts image.image_height
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment