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
require 'active_model' | |
class Person | |
include ActiveModel::Validations | |
attr_accessor :name, :age | |
def initialize(name: nil, age: nil) | |
@name = name | |
@age = age |
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
class Animal | |
attr_reader :distance | |
def initialize | |
@distance = 0 | |
end | |
def step! | |
@distance += 1 | |
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
def count_letters(text) | |
array = [] | |
text = text.downcase | |
text.each_char do |char| | |
if char =~ /[A-Za-z]+/ | |
count = text.count(char) | |
array << [char, count] | |
end | |
end | |
array = array.uniq |
NewerOlder