class BlogEntry
attr_accessor :title, :fulltext, :mood
end
entry = BlogEntry.new
entry.title = "Today Mt. Hood was stolen!"
entry.time = Time.now
entry.mood = :sick //another mothod
entry.fulltext = "BABABABA..."
//See what you have done
entry
//
class BlogEntry
def initialize( title, mood, fulltext )
@time = Time.now
@title, @mood, @fulltext = title, mood, fulltext
end
end
entry = BlogEntry.new("I left my Hoodie on the desk", "Today is interesting",
"I love you! Alice")
/*
Accessors are variables attached to an object which can be used outside the object. (entry.time = Time.now)
Instance variables are the same variables you're using for accessors when inside the object. Like in a method definition. (@time = Time.now)
*/
blog.each do |entry|
.. h1 "Zhentian"
.. h2 entry.title
.. p entry.fulltext
.. end
/**
Once you have Ruby installed, you can use Interactive Ruby by running irb on your system's command line utility.
*/