出现错误:./http.rb:13: # (NoMethodError) 的未定义方法“代码”
#!/usr/bin/ruby
require 'rubygems'
require 'httparty'
class Foo
include HTTParty
end
# Simple get with full url
r = Foo.get('http://www.google.com/')
p r.code
Include HTTParty 也将指定模块的方法代码添加到 Foo 类中。见混音!
module HTTParty
module AllowedFormatsDeprecation
def get
#...
end
end
end
将 HTTParty 混入 Foo 应该可以工作