- Twitter: @alinajaf
- Website or Blog: http://happybearsoftware.com/archive.html
- Company: Happy Bear Software Ltd. http://happybearsoftware.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# We prefer composition over inheritance because inheritance couples type to | |
# implementation. | |
# | |
# Take a look at this example using inheritance: | |
class Duck | |
def initialize | |
@wings = Wings.new | |
end |
- Twitter: @alinajaf
- Website or Blog: http://happybearsoftware.com/archive.html
- Company: Happy Bear Software Ltd. http://happybearsoftware.com
- Twitter: @alinajaf
- Website or Blog: http://happybearsoftware.com/archive.html
- Company: Happy Bear Software Ltd. http://happybearsoftware.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
require 'socket' | |
Socket.tcp_server_loop(ARGV[0].to_i) do |connection| | |
connection.write("Hello, world\n") | |
connection.close | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
require 'socket' | |
server = TCPServer.new ARGV.first.to_i | |
loop do | |
client = server.accept | |
client.puts "Hello, world" | |
client.close |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
require 'socket' | |
server = TCPServer.new ARGV.first.to_i | |
loop do | |
client = server.accept | |
client.write(client.readline) | |
client.close |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
require 'socket' | |
def log(source, message) | |
time = Time.now.strftime("%Y-%m-%d %H:%M:%S") | |
puts "[%s] %s => %s" % [time, source, message] | |
end | |
server = TCPServer.new ARGV.first.to_i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
require 'socket' | |
def log( source, message) | |
time = Time.now.strftime("%Y-%m-%d %H:%M:%S") | |
puts "[%s] %s => %s" % [time, source, message] | |
end | |
server = TCPServer.new ARGV.first.to_i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
require 'socket' | |
def log(source, message) | |
time = Time.now.strftime("%Y-%m-%d %H:%M:%S") | |
puts "[%s] %s => %s" % [time, source, message] | |
end | |
# Class representing HTTP Requests |