I can confirm this behavior in Ruby 1.9.3p448.
I think it's because in irb's repl the definitions are wrapped in singleton, so to imitate it just put following in your script:
class << self
def x; end
end
puts public_methods.member? :x # true