Refactoring Ruby

So if you read this title without knowing that I am learning some Ruby programming you may have started to picture me chipping away at at large red rock (ruby) to create the desired shape for my latest pendent…. well perhaps 😉

In some ways this visual could be true if the actual function of the object was not changed. In a nutshell Refactoring Ruby is basically analysing code and making changes that leaves it

CLEAN SIMPLe and EASY TO MAINTAIN

without effecting the function of the code!

A number of diferent ideas were intorduced and then I was given an opportunity to have a go! for example:

#loop6.times{puts “Melbourne in lockdown”}

or

lockdown=6

“I am in lockdown”+ lockdown.to.s +”!!!!”

#changes to

“I am in lockdown #{lockdown}!!!!”

Posted in Uncategorized | Comments Off on Refactoring Ruby

Creating my first app

Pulling together a number of concepts to create a simple app. I am still finding a lack of flow and need to practice a little more- perhaps some coding puzzles might help. THis code is all about verbs… doing code 😉 I used the concepts of  CRUD  

create, read, update, delete

Posted in Uncategorized | Comments Off on Creating my first app

Creating a Histogram Lockdown 6.0

Today was the first day of the 6th Lockdown for Melbourne. There is some solis in learning to code in amongst the croazy homeschooling and teaching…. I also have a deadline to try to get this pre learning done by the end of August. My struggle is coming down to a lack of practice and getting stuck on blocks.

My Code today cuts up a string, creates an array and looks at the frequency of word in a given input…….

Posted in Coding, methods, ruby, string, Uncategorized | Comments Off on Creating a Histogram Lockdown 6.0

Data Structures

After a small (lockdown induced break” I have started again now with a deadline set I am ploughing through. I am battling myself as a learner as my role as a teacher has sarted to be un undoing. I am frustrated with not completley understanding it and struggling with not having the language fluenency to help myself. I can read chemistry, biology, science, gardening, parently…. this Ruby language is new so I feel slow and clumsy.

Today my Hash.new, .each and putting data from arrays and array of arrays was on the menu.

Posted in Uncategorized | Comments Off on Data Structures

Redacted!

Woah this is getting a bit tricky… I wonder is it my remote teaching fatigue, having four children remote leanring at home, the wet weatehr or simply things are starting to ramp up! Today I redacted and use a .split method. But the big aaaahaaa moment was simply seeing strings and arrays and starting to get the idea of blocks…. I panic here and there about wher to put the next bit of code… today my take away you can have blocks in blocks!

My code from todays codecademy….. “I’m getting into REDACTED

Thought I might also tackle the additional question the first being about dropcase but the others will have to wait- this beginner is flaking out with brain lockdown fatigue……

Posted in Uncategorized | Comments Off on Redacted!

Loops and Iterators

This lesson was tough, with the school term starting back this week and today the start of lockdown 5.0 for Melbourne, I am somewhat tired…. but once I got my coding logical mind switched on I got the hang of creating loops. It seems Ruby has a heap of various ways to loop- I managed to create 3 infinate loops and crashed my codecademy learning site 3 times!

I am writing lots of notes in my note book as the retention of these new ideas is somewhat fleating and being able to reference my notes makes it all flow a lot better.

Next up Redaction

Posted in Uncategorized | Comments Off on Loops and Iterators

When “Tharah” became “Sarah”

So today was a .downcase!, .include? and .gsub! introduction…. I am struggling with some of my odering and recalling the simple things like adding a end after an if or else. With perserverance and concentrating- (a little hard with 4 children consentantly interrupting) I managed to figure it out.

Computer generated “Tharah”

This code basically takes an input drops it to lowercase hunts for the presence of the letter “s” and replaces any s the “th”. It is basically the reverese code of how my brothers speech therapist in the 1980’s taught hin to put his snake (aka tongue) behind its gate (aka teeth) and soon I became Sarah rather than Tharah.

Posted in methods, ruby | Tagged , , | Comments Off on When “Tharah” became “Sarah”

Control flow in Ruby

Woah this is when my maths logic really needs to boot in. The if, else, elsif, unless can really start to get tricky when considering you combine a whole heap of operators… particularly the and ones!

&& aka same as

!! aka inclusive

! aka not

and operators can get a bit tricky with your logical grey matter 😉
Posted in Uncategorized | Tagged , | Comments Off on Control flow in Ruby

Putting the form in formatter

After a short break I found my flow a little bumping at the start of the unit- a great reminder that a daily practice is going be hugely benefical for my learning. Today we chomped our way through creating a form…..

gets take the input from the user while chomp simple removes the extra line…..

The method to capitilize was forced to only be applies to the variable answer rather than the variable by simply making it “exciting”…… just add a ! to the end….

Now I wonder what a ? might do 😉

Posted in Uncategorized | Tagged , | Comments Off on Putting the form in formatter