This was a challenge for reddit #202 Easy /u/learnprogramming ...I wish that someone reviews my code and let me know your opinion about my way of thinking beacause I am a total beginner in Ruby:class BinaryChar  attr_accessor :binaryString  def convertToChar    binaryString.scan(/.{1,8}/) { |part| print part.to_i(2).chr }    puts  endendbc = BinaryChar.newspeak = 0 loop do  print Enter string:   speak = gets  bc.binaryString=(speak)  bc.convertToCharend
Binary convert to string in Ruby
beginner;ruby;programming challenge;converting
BinaryChar is a class with one method. You continually change the state of the object so you can call the method with the right argument. That's not what classes are for, but module functions or class methods. I rewrote the code twice: once using a class in the right way and once using a module function (or class method).with a classclass BinaryChar  def initialize(string)    @binary = string.scan(/.{1,8}/).map do |character|      character.to_i(2).chr    end  end  def to_s    @binary.join  endendloop do  print Enter string:   bc = BinaryChar.new(gets)  puts bc # to_s is called automatically by puts.endwith a module functionmodule Binary  def self.to_binary(string)    binary = string.scan(/.{1,8}/).map do |character|      character.to_i(2).chr    end    binary.join  endendloop do  print Enter string:   puts Binary.to_binaryendA couple of minor nitpicks:In ruby the convention is to use snake_case for anything but ClassNames and CONSTANTS.When you get input from stdin (gets) a newline is appended to it (\n). In most cases you want to strip the newline of using String#chomp.Accessor methods can look just like variable assignments: bc.binary_string = speak.Conversion methods are usually named to_<something>. To convert to a String, for example, most classes implement a to_s method.