#New Ruby project set-up checklist
touch README.md
- bin
- lib/models
- lib/views
| # Euler problem 3 | |
| # used my old prime method from school week 1 | |
| class LargestPrime | |
| def largest(number) | |
| Math.sqrt(number).to_i.downto(2) do |i| | |
| # prime factor is a prime number that divides the integer exactly | |
| return i if number % i == 0 && prime?(i) | |
| end | |
| end |
| require 'json' | |
| require 'rest-client' | |
| r = JSON.parse(RestClient.get('http://reddit.com/.json')) | |
| p = r["data"]["children"] | |
| posts_array = p.collect { |post| post["data"] } | |
| # posts_array is an array of post hashes | |
| # you can iterate over posts_array or do posts_array[0]["url"] |
Morgan Evans
GitHub: NegaMorgan
BlogURL: http://negamorgan.github.io
Tagline: "Keep calm and clear cache."
Treehouse: http://teamtreehouse.com/NegaMorgan