Skip to content

Ror assignment day 04#3

Open
YashShah-Josh wants to merge 7 commits intomasterfrom
ROR-Assignment-Day-04
Open

Ror assignment day 04#3
YashShah-Josh wants to merge 7 commits intomasterfrom
ROR-Assignment-Day-04

Conversation

@YashShah-Josh
Copy link
Owner

No description provided.

Comment on lines 19 to 21
class MilitaryAndDefenseAnalysis
include MilitaryAndDefense
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already being defined above. Please remove this.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have removed it

puts "Economic Analysis Tool"

print "Enter the country name: "
country_name = gets.chomp.split.map(&:capitalize).join(' ')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
country_name = gets.chomp.split.map(&:capitalize).join(' ')
country_name = gets.chomp.squish.titleize

Can you please check if this does the same?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it does the same work. I have actually checked capitalize but it didn't work hence I used it

puts "Military and Defense Analysis Tool"

print "Enter the country name: "
country_name = gets.chomp.split.map(&:capitalize).join(' ')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes corrected

puts "Loan Eligibility Tool"

print "Enter the country name: "
country_name = gets.chomp.split.map(&:capitalize).join(' ')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes corrected

gdp = Integer(gets.chomp)

print "Enter the Debt: "
debt = Integer(gets.chomp)
Copy link
Collaborator

@RajatKawale RajatKawale Jan 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it's better to use Integer only in the above cases also instead of to_i.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it will be better. I will modify it

loan = LoanEligibilityTool.new
puts loan.details(country_name, gdp, debt) # Adjust the values as needed

rescue Error => e
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a single rescue block for this entire case clause instead of having individual rescue block for all different cases? As i can see the message is same for all rescue block.

# end
else
puts "Invalid choice"
end No newline at end of file
Copy link
Collaborator

@RajatKawale RajatKawale Jan 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case will only execute once per execution of the file. What if i want to repeat this until the user choose a specific option to exit like option 4: type 'exit' to quit. Can you make it like this?
Also the size of each case block is too long, i think it's better to split it in methods for each case block.


# Debt sustainability based on GDP and debt ratio
def debt_sustainability(country_name, gdp, debt)
if is_imf_member?(country_name)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we checking this again when we have already checked this in loan_eligibility method?

end

# Check if the country is committed to reforms
def commitment_to_reforms(country_name)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again why this method?

if is_imf_member?(country_name)
debt_sustainability(country_name, gdp, debt) && commitment_to_reforms(country_name) ? "Loan is approved" : "Loan is not approved"
else
"Country is not a member of IMF"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Country is not a member of IMF"
"Country is not a member of IMF so loan can't be approved"


# Method to assess cybersecurity preparedness
def cybersecurity_preparedness(total_incidents, resolved_incidents)
return 'Total incidents cannot be zero' if total_incidents == 0
Copy link
Collaborator

@RajatKawale RajatKawale Jan 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if there are no incidents occurred for that country?
There should be validation that total_incidents and resolved_incidents shouldn't be in negative and resolved_incidents shouldn't be greater than total_incidents should get checked before going into case clause.

Comment on lines 2 to 8
module DebtGdpRatio
# Method to calculate debt-to-GDP ratio
def self.debt_gdp_ratio(gdp, debt)
return 'GDP cannot be zero' if gdp == 0
(debt.to_f / gdp.to_f) * 100
end
end
Copy link
Collaborator

@RajatKawale RajatKawale Jan 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can create a new separate module file for this module and include it in all other modules instead of defining this same module in each other individual module.

end

# Define module EconomicAnalysis
module EconomicAnalysis
Copy link
Collaborator

@RajatKawale RajatKawale Jan 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After moving DebtGdpRatio into separate file you can include that in this file like below.

Suggested change
module EconomicAnalysis
module EconomicAnalysis
include DebtGdpRatio

Same goes for the other modules.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants