def listen_thread
Thread.abort_on_exception = true
@thread = Thread.new do
loop do
sleep 0.1
str = nil
begin
@connection.set_encoding('UTF-8')
str = @connection.gets.chomp
if str.nil? then
next
else
@success.full_received_message = JSON.parse(str)
end
rescue => ex
@success.error_message = "#{@messages.error_parse_receive_message} - #{ex}"
next
end
@stop = true
end
end
end
require 'json'
b = {:a=>1,:o=>2}
b.each_key{|k|
p k
}
a='?{a:po}'
a=a.to_json
a.each_key{|k|
p k
}
require 'json'
b = {:a=>1,:o=>2}
b.each_key{|k|
p k
}
a='?{a:po}'
p a.to_json
a.each_key{|k|
p k
}
class MyString < String
def is_wtf_string?
self == 'wtf'
end
end
a = MyString.new
a = 'wtfo'
p a.is_wtf_string? #=> true