Hydrogen

This is a Hydrogen API Ruby client library. As the Hydrogen API is updated there will be a simultaneous update of this library.

Requirements

  • HTTParty
  • Mash

Install

Easiest install is via RubyGems:

$ gem install hydrogen

or

$ gem sources -a http://gems.github.com/ (you only need to do this once)
$ gem install redflex-hydrogen-ruby

The gem from GitHub will generally by available sooner than the gem from Rubyforge. Both sources will eventually contain the same releases.

Source

Hydrogen's Git repo is available on GitHub, which can be browsed at:

http://github.com/redflex/hydrogen-ruby

and cloned with:

git clone git://github.com/redflex/hydrogen-ruby.git

Usage

Hydrogen-ruby gives you object model access to the Hydrogen API. Once you have created a client object, you can traverse it to find topics and comments.

Initialize a Client Object

The first step is to create a Hydrogen::Base object to represent your client.

require 'hydrogen'
client = Hydrogen::Base.new('redflex')

In the above example, the Hydrogen account is redflex (this is the same as account.hydrogenapp.com, not your user name).

Getting a list of topics

From the Base object you can get a list of topics as an array. This defaults to the last 15 topics to be created, as specified in the Hydrogen API.

client.topics.each { |topic| puts topic.inspect }

You can also pass any Hydrogen API parameters to this method, for example:

client.topics({ :page => 1 }).each { |topic| puts topic.inspect }

You can also get a single topic. Note: this method is topic and **not* topics*.

client.topic( topic_id ).inspect

Getting a list of comments

You can also get a list of comments from the Base object. You will, of course, need to know the topic_id.

client.comments( topic_id ).each { |comment| puts comment.inspect }