-
Continue to solidify your understanding of basic Ruby programming concepts
-
Be prepared to learn about Ruby libraries on Tuesday
- Create a program to analyze a large block of text and report back on the frequency of each word in the text.
<h1>Posts for one user:</h1> | |
<% @posts.each do |post| %> | |
<%= post.title %> | |
<% end %> |
class PostsController < ApplicationController | |
def index | |
@posts = Post.all | |
end | |
def show | |
@post = Post.find_by_id(params[:id]) | |
end | |
def edit |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Railsapp4</title> | |
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> | |
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> | |
<%= csrf_meta_tags %> | |
</head> | |
<body> |
{ | |
"A"=>1, "B"=>3, "C"=>3, "D"=>2, | |
"E"=>1, "F"=>4, "G"=>2, "H"=>4, | |
"I"=>1, "J"=>8, "K"=>5, "L"=>1, | |
"M"=>3, "N"=>1, "O"=>1, "P"=>3, | |
"Q"=>10, "R"=>1, "S"=>1, "T"=>1, | |
"U"=>1, "V"=>4, "W"=>4, "X"=>8, | |
"Y"=>4, "Z"=>10 | |
} |
require 'geolocater' | |
record = Geolocater.geolocate_ip("64.119.207.255") | |
puts record |
Bonus scenarios such as double word or triple letter scores should not be taken into account
def america_phrase(phrase) | |
"#{phrase}; Only in America!" | |
end | |
puts "Enter a phrase" | |
input = gets.chomp | |
puts america_phrase(input) |