Skip to content
This repository was archived by the owner on Aug 2, 2021. It is now read-only.

Commit 472e498

Browse files
committed
new movie screenshot + new formatting on movie script
1 parent 5fb6477 commit 472e498

File tree

3 files changed

+34
-19
lines changed

3 files changed

+34
-19
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Ruby-Scripts
22

33
## Installation
4-
Download folder as zip
4+
Download folder as zip
55
```bash
66
gem install rest-client
77
```
@@ -26,4 +26,4 @@ ruby stocks.rb
2626
## Movie Search - Uses OMDB API to return movie data
2727
Update => OMBD API is now private, and requires an API key for use
2828

29-
![](https://media.giphy.com/media/xUPGcxoW2iL5y3R4c0/giphy.gif)
29+
![Imgur](http://i.imgur.com/3qTNcNY.png)

movie_search/movie.rb

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,46 @@
33

44
require 'Rest-Client'
55
require 'json'
6+
require 'word_wrap'
67

7-
def movie_search()
8-
print "Enter a movie title -> "
8+
# Word wrapping method
9+
def wrap(s, width=78)
10+
s.gsub(/(.{1,#{width}})(\s+|\Z)/, "\\1\n| ")
11+
end
12+
13+
def movie_search
14+
15+
api_key = "1234567"
16+
17+
print "Movie => "
918
movie_name = gets.chomp
10-
url = "http://www.omdbapi.com/?t=#{movie_name}"
19+
url = "http://www.omdbapi.com/?t=#{movie_name}&apikey=#{api_key}"
1120
response = RestClient.get(url)
1221
info = JSON.parse(response)
1322

1423
title = info["Title"]
1524
year = info["Year"]
16-
score = info["Metascore"]
25+
score = info["Ratings"][1]["Value"]
1726
rated = info["Rated"]
1827
genre = info["Genre"]
1928
director = info["Director"]
20-
actors = info["Actors"]
21-
plot = info["Plot"]
22-
23-
puts "Title: #{title}"
24-
puts "Year: #{year}"
25-
puts "Metascore: #{score}"
26-
puts "Rated: #{rated}"
27-
puts "Genre: #{genre}"
28-
puts "Director: #{director}"
29-
puts "Actors: #{actors}"
30-
puts "Plot: #{plot}"
31-
end
29+
actors = wrap(info["Actors"], 48)
30+
plot_unformatted = info["Plot"]
31+
32+
plot = wrap(plot_unformatted, 48)
3233

33-
movie_search()
34+
puts ""
35+
puts "=================================================="
36+
puts "| Title: #{title}"
37+
puts "| Year: #{year}"
38+
puts "| Tomato: #{score}"
39+
puts "| Rated: #{rated}"
40+
puts "| Genre: #{genre}"
41+
puts "| Director: #{director}"
42+
puts "| Actors: #{actors}"
43+
puts "| Plot: #{plot}"
44+
puts "=================================================="
45+
puts ""
46+
end
3447

48+
movie_search

stock_search/stocks.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
require 'json'
66

77
def stock_search
8+
89
# Cptures user inputs
910
puts ""
1011
print "Stock => "

0 commit comments

Comments
 (0)