class Sakaki

Public Instance Methods

get(location, query="") click to toggle source
# File lib/sakaki.rb, line 46
def get(location, query="")
  socket = TCPSocket.new("gopher.dangeru.us", 70)

  if query.empty? then
    socket.print location + "\n"
  else
    socket.print location + "\t" + query + "\n"
  end
  response = socket.read

  return response[0..-5]
end
get_boards() click to toggle source

Gets all boards with their descriptions Returns a hash of arrays

# File lib/sakaki.rb, line 28
def get_boards
  return JSON.parse(get(API + "boards"))
end
get_thread_replies(id) click to toggle source

Gets replies from thread Returns a hash of arrays

# File lib/sakaki.rb, line 21
def get_thread_replies(id)
  return JSON.parse(get(API + "thread/" + id.to_s))
end
index_board(board) click to toggle source

Indexes a board Returns a hash of arrays

# File lib/sakaki.rb, line 14
def index_board(board)
  return JSON.parse(get(API + "board/" + board))
end
new_thread(board, title, comment) click to toggle source

Creates a new thread Returns nothing

# File lib/sakaki.rb, line 42
def new_thread(board, title, comment)
  get("/" + board + "/post/" + Base64.urlsafe_encode64(title), comment)
end
reply(id, board, comment) click to toggle source

Replies to a thread Returns nothing

# File lib/sakaki.rb, line 35
def reply(id, board, comment)
  get("/" + board + "/reply/" + id.to_s, comment)
end