class Tortilla::RequestBuilder

Attributes

headers[RW]
response_parser[RW]
url[RW]

Public Class Methods

new() click to toggle source
# File lib/tortilla.rb, line 10
def initialize
  @url = ""
  @headers = {}
  @response_parser = nil
end

Public Instance Methods

get(*args) click to toggle source
# File lib/tortilla.rb, line 26
def get(*args)
  puts @url
  response = HTTParty.get(@url)
  if(!@response_parser.nil?)
    parsed = @response_parser.call(response)
  else
    parsed = JSON.parse(response.body)
  end

  return parsed
end
method_missing(meth,*args,&block) click to toggle source
# File lib/tortilla.rb, line 16
def method_missing(meth,*args,&block)
  @url = @url+"/"+meth.to_s

  if(!args.first.nil? && !args.nil?)
    @url+"/"+args.first
  end

  return self
end