Module: Love::ResourceURI

Included in:
Client
Defined in:
lib/love.rb

Instance Method Summary collapse

Instance Method Details

#collection_uri(input) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/love.rb', line 22

def collection_uri(input)
  case input.to_s
  when /^[\w-]+$/
    ::URI.parse("https://api.tenderapp.com/#{}/#{input}")
  when %r[^https?://api\.tenderapp\.com/#{}/[\w-]+]
    ::URI.parse(input.to_s)
  else
    raise Love::Exception, "This does not appear to be a valid Tender category URI!"
  end
end

#singleton_uri(input, kind) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/love.rb', line 33

def singleton_uri(input, kind)
  case input.to_s
  when /^\d+/
    ::URI.parse("https://api.tenderapp.com/#{}/#{kind}/#{input}")
  when %r[^https?://api\.tenderapp\.com/#{}/#{kind}/\d+]
    ::URI.parse(input.to_s)
  else
    raise Love::Exception, "This does not appear to be a Tender #{kind} URI or ID!"
  end
end