Skip to content

Instantly share code, notes, and snippets.

# -*- coding: utf-8 -*-
class SimpleApp
def call(env)
p env
case env['REQUEST_METHOD']
when 'GET'
[
200,
{ 'Content-Type' => 'text/html' },
['<html><body><form method="POST"><input type="submit" value="want to see?" /></form></body></html>']
require './test.rb'
run(SimpleApp.new)
# -*- coding: utf-8 -*-
class SimpleApp
def call(env)
p env
case env['REQUEST_METHOD']
when 'GET'
[
200,
{ 'Content-Type' => 'text/html' },
['<html><body><form method="POST"><input type="submit" value="want to see?" /></form></body></html>']
# Bridge パターン
#
# Java言語で学ぶデザインパターンと同様の例題をRubyで記述した。
#
# coded by Takehiro Kaga
#
class Display
def initialize(impl)
@impl = impl
class Display
def initialize(impl)
@impl = impl
end
def open
@impl.rawOpen
end
def printf
@impl.rawPrint
+-------------+
|Hello, Japan.|
+-------------+
(Hello, World.)
(Hello, Universe.)
+------+
|Hello!|
+------+
()
(Hello, Universe.Hello, Universe.Hello, Universe.Hello, Universe.Hello, Universe.)
+-------------+
|Hello, Japan.|
+-------------+
+-------------+
|Hello, World.|
+-------------+
+----------------+
|Hello, Universe.|
+----------------+
+----------------+
class Display
def initialize(impl) @impl = impl end
def open @impl.rawOpen end
def printf @impl.rawPrint end
def close @impl.rawClose end
def display
open
printf
close
end
class Display
def initialize(impl) @impl = impl end
def open @impl.rawOpen end
def printf @impl.rawPrint end
def close @impl.rawClose end
def display
open
printf
close
end