Very new to ruby. I'm trying to see if I can write html using ruby. Very basic script. No errors but nothing is written to the file and I can't figure out why. If I use puts
after mypage
I can see the html written to the console
#!/usr/bin/env ruby
class MyPage
attr_accessor :para, :startbuff
def initialize
@para = "<p>"
@startbuff = "<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />
<title>Your Website</title>
</head>
<body>
</body>
</html>"
end
def makePage
puts @startbuff
end
end
mypage = MyPage.new
File.open("/Users/me/Desktop/MyRubyHTML.html", "w+").each { |file|
puts mypage.makePage
}