Skip to content

Instantly share code, notes, and snippets.

@AttyC
AttyC / cat.rb
Created June 16, 2015 12:20
Cat updated to include parent Pet class and Dog class
class Pet
attr_reader :color, :breed
attr_accessor :name
def initialize (color, breed)
@color = color
@breed = breed
@hungry = true
end
def feed(food)
class Cat
attr_reader :color, :breed
attr_accessor :name
def initialize (color, breed)
@color = color
@breed = breed
@hungry = true
end
def feed(food)
def fav_foods
food_array = []
3.times do
puts "Name a favourite food"
food_array << gets.chomp
p food_array
puts "Your favourite foods are #{food_array.join(", ")}."
food_array.each do |food|
puts "I like #{food} too!"
@AttyC
AttyC / program2.rb
Created June 8, 2015 13:20
Ruby loops and conditionals
if (5+5==10)
puts "this is true"
else
puts "this is false"
end
def greeting
puts "Please enter your name:"
name = gets.chomp
puts "hello" + " " + name
end
greeting
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Atty's Web Portfolio</title>
<!-- Twitter button -->
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Atty's Web Portfolio</title>
<!-- Twitter button -->
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<!-- /Twitter -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Atty's Web Portfolio</title>
<!-- Twitter button -->
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<!-- /Twitter -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Atty's Web Portfolio</title>
<!-- Twitter button -->
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<!-- /Twitter -->
@AttyC
AttyC / index.html
Created May 12, 2015 12:39
scripts.js
$(document).ready(function(){
$(".message-box").css("background-color","#ccc");
$("#contact_button").on("click", function() {
var comment = $(".message-box").val();
$("#visible_comment").html(comment.toUpperCase() + "! jQuery is working beautifully!");
return false;
});
});