This file contains 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
# luhn.rb | |
class Luhn | |
def initialize(input) | |
@input = input.delete(' ') # on enlève tous les espaces | |
end | |
def self.valid?(input) | |
new(input).valid? | |
end | |
This file contains 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
module ClassMethods | |
# ce module sera "inclus" avec extend, donc | |
# toutes les méthodes de ce module seront des méthodes de classe | |
# les 2 méthodes ci-dessous, ressemblent à attr_accessor mais "de classe". | |
# l'idée est d'utiliser non pas des variables de classe (@@ids) mais des | |
# variables d'instances de classe (à ne pas confondre avec les variables d'instance) | |
# puisque une classe est aussi un objet en Ruby | |
def ids | |
@ids ||= 0 |
This file contains 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
rvm install ruby-2.5.1 | |
ruby-2.5.1 - #removing src/ruby-2.5.1.. | |
Searching for binary rubies, this might take some time. | |
No binary rubies available for: fedora/28/x86_64/ruby-2.5.1. | |
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies. | |
Checking requirements for fedora. | |
Requirements installation successful. | |
Installing Ruby from source to: /home/quark/.rvm/rubies/ruby-2.5.1, this may take a while depending on your cpu(s)... | |
ruby-2.5.1 - #downloading ruby-2.5.1, this may take a while depending on your connection... | |
ruby-2.5.1 - #extracting ruby-2.5.1 to /home/quark/.rvm/src/ruby-2.5.1..... |