module RubyChina::Helpers

Public Instance Methods

describe(topic) click to toggle source
# File lib/rubychina/helpers.rb, line 16
def describe(topic)
  puts %{\033[1m#{topic['id']}: 回复数量 [#{topic['replies_count']}]  "#{topic['title']}    "\033[0m}.green
  puts topic['body'].yellow
  puts "#" * 20
  topic['replies'].each do |r|
    puts r['user']['login'].red
    puts "\t" * 2  + r['body']
    puts "=" * 20
  end
  puts
end
get(path) { |response| ... } click to toggle source
# File lib/rubychina/helpers.rb, line 7
def get(path)
  response = Excon.get("http://ruby-china.org/api" + path)
  say_error "Error #{response.status}" and abort unless response.status == 200

  yield response if block_given?

  JSON.parse(response.body)
end

Private Instance Methods

client() click to toggle source
# File lib/rubychina/helpers.rb, line 30
def client
end