Skip to content

Instantly share code, notes, and snippets.

View zgfif's full-sized avatar
🙃

Pasha Bratanov zgfif

🙃
  • Odesa, Ukraine
View GitHub Profile
require 'active_model'
class Person
include ActiveModel::Validations
attr_accessor :name, :age
def initialize(name: nil, age: nil)
@name = name
@age = age
@zgfif
zgfif / program2_animal.rb
Last active December 24, 2018 11:03
Animal
class Animal
attr_reader :distance
def initialize
@distance = 0
end
def step!
@distance += 1
end
@zgfif
zgfif / program1.rb
Created December 15, 2018 20:24
Реалізувати програму, яка буде приймати аргументом рядок (String) і рахувати скільки разів зустрічається кожна літера в цьому рядку.
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