Skip to content

Instantly share code, notes, and snippets.

@VladHurma
Last active November 28, 2018 22:51
Show Gist options
  • Save VladHurma/4acaeef10fa41cb325b99231a5768a85 to your computer and use it in GitHub Desktop.
Save VladHurma/4acaeef10fa41cb325b99231a5768a85 to your computer and use it in GitHub Desktop.
# 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
Copy link

  1. следи, чтобы названия переменных были осмысленными: @string - это безликая строка - о чем это ты вообще? Лучше user_input_string, user_answer и т.п. на твое усмотрение, но со смыслом, чтобы коллега быстро догадался зачем ты используешь переменную
  2. опять print "#{@words_amount}\n"
  3. отступы 2 пробела везде

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment