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
Rehearsal ---------------------------------------------------- | |
using httpclient 0.570000 0.280000 0.850000 ( 42.646417) | |
using EM 0.140000 0.130000 0.270000 ( 3.381920) | |
------------------------------------------- total: 1.120000sec | |
user system total real | |
using httpclient 0.520000 0.230000 0.750000 ( 28.525617) | |
using EM 0.140000 0.130000 0.270000 ( 3.902702) |
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
AmazeSNS.list_topics do |resp| | |
response = Crack::XML.parse(resp.response) | |
# do further processing here | |
EM.stop | |
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
# something trivial but might be helpful if you want to implement clearing the session hash when the user presses the | |
# Back button | |
# used in IQF project when the email contact link on top right of page has to show the title of current page | |
def clear_session | |
response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate" | |
response.headers["Pragma"] = "no-cache" | |
response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT" | |
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
class Vehicle | |
def start_engine | |
# start the engine | |
end | |
def stop_engine | |
#stop the engine | |
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
class Engine | |
def initialize | |
# set engine properties here etc | |
end | |
# other engine methods | |
end | |
class Car < Vehicle |
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
class Report | |
def initialize | |
@title = 'Monthly Report' | |
@text = ['Things are going', 'really, really well.'] | |
end | |
def output_report(format) | |
if format == :plain | |
puts("*** #{@title} ***") | |
elsif format == :html |
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
class Report | |
def initialize | |
@title = 'My Report' | |
@text = ['Lorem’, ‘Ipsum'] | |
end | |
end | |
def output_report | |
output_start | |
output_head |
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
class HTMLReport < Report | |
def output_start | |
puts('<html>') | |
end | |
def output_head | |
puts(' <head>') | |
puts(" <title>#{@title}</title>") | |
puts(' </head>') |
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
require 'singleton' | |
class MyClass | |
attr_accessor :data | |
include Singleton | |
end | |
a = MyClass.instance | |
b = MyClass.instance |
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
require 'singleton' | |
class SimpleLogger | |
include Singleton | |
attr_accessor :level | |
ERROR=1 | |
WARNING=2 | |
INFO=3 |
OlderNewer