Greentext Unofficial 4chan's JSON API Wrapper for Ruby.
Installation
Add this line to your application's Gemfile:
gem "greentext"
And then execute:
$ bundle
Or install it yourself as:
$ gem install greentext
Usage
require "greentext"
client = Greentext.client
# => #<Greentext::Client:0x007f9f9a624260 @api_endpoint="http://a.4cdn.org/">
board = client.boards.first
# => #<Greentext::Board:0x007f9f9aa10928 @attrs={"board"=>"3", "title"=>"3DCG", "ws_board"=>1, ... }>
board.title
# => "3DCG"
board.worksafe?
# => true
thread = board.threads.first
# => #<Greentext::Post:0x005f4f9aa12393 @attrs={"no"=>240555661, "now"=>"04\/21\/14(Mon)13:26:27", ... }>
thread.time
# => #<DateTime: 2014-04-21T18:24:10+00:00 ((2456769j,66250s,699039399n),+0s,2299161j)>
thread.comment
# => "Love it. Looks like there's going to be ton of secret ... "
# Get the rest of the thread from OP's post
all_posts = thread.
# => [#<Greentext::Post:0x005f4f9aa26345>, #<Greentext::Post:0x005f4f9aa27456>
Contributing
- Fork it ( http://github.com/avidw/greentext/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Install development requirements (
bundle install
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
This project follows the Ruby Style Guide aside from a couple of differences:
- Documented using TomDoc instead of RDoc.
- Double quotes are always preferred over single quotes unless escaping them becomes a nightmare.
- There are no spaces around
=
for default arguments in a method. This is just a personal thing.
Double check the code using bundle exec rubocop
before submitting a pull request.