Last active
November 28, 2018 22:51
-
-
Save VladHurma/4acaeef10fa41cb325b99231a5768a85 to your computer and use it in GitHub Desktop.
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
# frozen_string_literal: true | |
class Find_words_amount | |
def initialize | |
@words_amount | |
end | |
def self.run | |
new.run | |
end | |
def run | |
ask_user_for_string | |
find_amount | |
show_user_sorted_words | |
end | |
private | |
def ask_user_for_string | |
puts 'Put here string to find words amount!' | |
@user_anser = gets.strip | |
end | |
def find_amount | |
@words_amount = @user_anser.split(' ').size | |
end | |
def show_user_sorted_words | |
p @words_amount | |
end | |
end | |
Find_words_amount.run |
aya-soft
commented
Nov 28, 2018
- следи, чтобы названия переменных были осмысленными: @string - это безликая строка - о чем это ты вообще? Лучше user_input_string, user_answer и т.п. на твое усмотрение, но со смыслом, чтобы коллега быстро догадался зачем ты используешь переменную
- опять print "#{@words_amount}\n"
- отступы 2 пробела везде
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment