Skip to content

Instantly share code, notes, and snippets.

@joevandyk
Created August 3, 2008 03:11
Show Gist options
  • Save joevandyk/3795 to your computer and use it in GitHub Desktop.
Save joevandyk/3795 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'httparty'
module Shack
class Comment
attr_reader :username, :body, :preview, :comment_id
def initialize comment
@username = comment["author"]
@preview = comment["preview"].gsub("\n", ' ')
@comment_id = comment["comment_id"]
@body = comment["body"]
end
def to_s
"#{ @username } said '#{ @preview }...'"
end
end
class Chat
include HTTParty
format :xml
base_uri "http://latestchatty.beautifulpixel.com"
attr_accessor :comments
def initialize
@comments = []
response = self.class.get("/")["comments"] # Get comments
response["comment"].each do |comment|
@comments << Comment.new(comment)
end
end
end
end
chat = Shack::Chat.new
first_comment = chat.comments.first
puts first_comment
puts
puts first_comment.body
# The above outputs:
# glio1337 said 'Windows Vista I'm running Windows XP Pro SP3 right now. I have 2GB of RAM, an Intel Q6600 (quad-core...'
#
# <span class="jt_blue">Windows Vista</span>
# <br />
# <br />I'm running Windows XP Pro SP3 right now. I have 2GB of RAM, an Intel Q6600 (quad-core) and an 8800GTS 640mb.
# <br />
# <br />I've been hearing around that if you have the hardware, now is a good time to make the jump to Vista. Are there any major complaints about Vista still from any current users? I figure I'll make the upgrade at some point, as I'm sure the next Windows is going to be delayed anyway. Right now I've got a few games that use DirectX 10 for stuff, such as Crysis and Brothers in Arms.
# <br />
# <br />And if I were to make the jump, would I be okay with getting the upgrade version of Home Premium, or should I get the full version? I like to reformat and start fresh at least once a year so I'm assuming the full version would make that easier unless I'm mistake. I've never used an upgrade version of Windows before.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment