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
| class LinkedListNode | |
| attr_accessor :value, :next_node | |
| def initialize(value, next_node=nil) | |
| @value = value | |
| @next_node = next_node | |
| end | |
| end | |
| def print_values(list_node) | |
| if list_node |
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
| class Fixnum | |
| def digits | |
| to_s.split('').map(&:to_i) | |
| end | |
| def luhn? | |
| luhn_checksum % 10 == 0 | |
| end | |
| def luhn_checksum |
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
| class Image | |
| attr_accessor :original_image, :image | |
| def initialize(image) | |
| @original_image = image | |
| end | |
| def image | |
| @image ||= @original_image.dup | |
| end |
OlderNewer