Question
Create the following for the code below: RUBY CODE Part one is complete. Part two: Create the ruby code that define a method starts_with_consonant?(s) that
Create the following for the code below: RUBY CODE
Part one is complete.
Part two: Create the ruby code that define a method starts_with_consonant?(s) that takes a string and returns true if it starts with a consonant and false otherwise. (For our purposes, a consonant is any letter other than A, E, I, O, U.)
Be sure it works for both upper and lower case and for nonletters!
Part three:
Create the ruby code that define a method binary_multiple_of_4?(s) that takes a string and returns true if the string represents a binary number that is a multiple of 4.
be sure it returns false if the string is not a valid binary number!
The code will be placed here.
1 require 'rubybasics2.rb 3 RSpec.configure do |configl config.filter-run-excluding :disabled => truel 5 end describe "#hello" do it "should be defined" do { hello("Testing") }.not-to raise-error()#: :NoMethodError) expect end 10 it "The hello method returns the correct string [30 points]", points: 30 do 12 13 14 expect (hello("Dan").class).to eq(String) expect (hello("Dan")).to eq( 'Hello, Dan), "Incorrect results for input: "Dan\ expect (hello("BILL")).to eq ('Hello, BILL, "Incorrect results for input: \"BILL\"" expect (hello("Mr. Ilson)).to eq' Hello, Mr. Ilson), "Incorrect results for input: \"Mr. Ilson\"" 16 17 18 19 20 21 end end describe "#starts-with-consonant?", :disabled => true do it "should be defined" do { starts-with-consonant ? ("d") }.not_to raise-error()#: :NoMethodError) expect end 23 24 it 'classifies true cases [10 points], points: 10 do 25 26 27 28 29 30 it 'classifies false cases [10 points]' , points: 10 do 31 32 expect (starts with consonant?('v.to be truthy, "'v'is a consonant" 'v 'vest', 'Veeee, 'crypt'.each do Istringl expect(starts-with-consonant ? (string)).to end "Incorrect results for input : \"#1string}\"" be_truthy, end expect (starts with consonant? ('a.to be falsy,"'a' is not a consonant" I'asdfgh', 'Unix'].each do string expect(starts-with-consonant ? (string)).to end befalsy, "Incorrect for input : \"#1string}\"" results 34 35 36 37 end it 'works on the empty string [5 points]', points: 5 do expect(starts_with_consonant?()).to be falsy
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started