Continuing to Learn Some Ruby

in #programming7 years ago (edited)

I have been spending some time here and there learning Ruby on Codeacedemy. Currently, I am on the Hashes and Symbols section.

Screenshot.png

Just having some fun and wrote up a little easy script from the example on the site.

Code:

steemians = {
  bitcoinparadise: 65,
  fyrstikken: 72,
  seablue: 61
}

puts "What would you like to do?"
puts "-- Type 'add' to add a steemian."
puts "-- Type 'update' to update a steemian."
puts "-- Type 'display' to display all steemians."
puts "-- Type 'delete' to delete a steemian."

choice = gets.chomp.downcase
case choice
when 'add'
  puts "What steemian do you want to add?"
  name = gets.chomp
  if steemians[name.to_sym].nil?
    puts "What's their rep?
(Type a number 0 to 99.)"
    rep = gets.chomp
    steemians[name.to_sym] = rep.to_i
    puts "#{name} has been added with a rep of #{rep}."
  else
    puts "That steemian already exists! Their rep is #{steemians
[name.to_sym]}."
  end
when 'update'
  puts "What steemian do you want to update?"
  name = gets.chomp
  if steemians[name.to_sym].nil?
    puts "Steemian not found!"
  else
    puts "What's the new rep?(Type a number 0 to 99.)"
    rep = gets.chomp
    steemians[name.to_sym] = rep.to_i
    puts "#{name} has been updated with new rep of #{rep}."
  end
when 'display'
  steemians.each do |steemian, rep|
    puts "#{steemian}: #{rep}"
  end
when 'delete'
  puts "What steemian do you  want to delete?"
  name = gets.chomp
  if steemians[name.to_sym].nil?
    puts "Steemian not found!"
  else
   steemians.delete(name.to_sym)
    puts "#{name} has been removed."
  end
else
  puts "Sorry, I didn't understand you."
end


Here's a little gif of what the script does:

It's not much but I'm still learning and understanding a bit more. I wish I could take more time out of my day to keep at it and be a better coder someday but life has got me busy with a lot these days.

I am amazed by those that know a ton of different programming languages. I only wished I had learned more when I was younger.

About Ruby

Created by Yukihiro “Matz” Matsumoto, he took some of his favorite languages(Perl, Smalltalk, Eiffel, Ada, and Lisp) to form Ruby.

Matsumoto has often said he is:

“trying to make Ruby natural, not simple,” in a way that mirrors life.

Ruby is simple in appearance, but is very complex inside, just like our human body.

Released in 1995, only recently reached mass acceptance in 2006 and is in the top 10 on most of the indices that measure the growth and popularity of programming languages worldwide.

Ruby is free to use, copy, modify, and distribute.

https://www.ruby-lang.org




Image Source


Thank you for taking the time to read my post.

Feel free to follow and find me in SteemSpeak on Discord.

Sort:  

Interesting that so much time passed from its release its adoption. Who else uses Ruby to code off Steem's blockchain. Is there an example of what Ruby was used for? There's so much development going on, I still haven't wrapped my head around the development side of Steem.

There's a lot to the development side that I'm still learning. As far as examples of what ruby is used for, @inertia is a great programmer in this language. You can check out his app catalog here:
https://steemit.com/radiator/@inertia/my-app-catalog

Thanks, this is exactly what I was needing.

Professional and experienced rubyist here! Feel free to ask me questions if you want help. Keep up the good work and I hope you enjoy what you are learning.

That's awesome! I would recommend following @inertia, he's a very experienced rubyist as well. I will definitely ask you some questions! Thank you for your comment and I am very much enjoying learning this language :)

I already follow @inertia! We're not a lot yet on Steemit, but I guess it's a matter of time :)

Hello! Your post has been resteemed and upvoted by @ilovecoding because we love coding! Keep up good work! Consider upvoting this comment to support the @ilovecoding and increase your future rewards! ^_^ Steem On!

Reply !stop to disable the comment. Thanks!

very good information, thank you mr. @bitcoinparadise

Great example. It's more than I can do :-)

Coin Marketplace

STEEM 0.30
TRX 0.11
JST 0.033
BTC 63968.82
ETH 3136.80
USDT 1.00
SBD 4.28