Skip to content

Commit 220ff3f

Browse files
[DOC] Enhanced RDoc for Net::HTTP (#123)
1 parent 06f79cd commit 220ff3f

File tree

1 file changed

+96
-22
lines changed

1 file changed

+96
-22
lines changed

lib/net/http.rb

Lines changed: 96 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,7 +1634,7 @@ def get(path, initheader = nil, dest = nil, &block) # :yield: +body_segment+
16341634
# returns an instance of a subclass of Net::HTTPResponse.
16351635
#
16361636
# The request is based on the Net::HTTP::Head object
1637-
# created from string +path+ and initial headers hash +initheader+.
1637+
# created from string +path+ and initial headers hash +initheader+:
16381638
#
16391639
# res = http.head('/todos/1') # => #<Net::HTTPOK 200 OK readbody=true>
16401640
# res.body # => nil
@@ -1709,66 +1709,140 @@ def patch(path, data, initheader = nil, dest = nil, &block) # :yield: +body_segm
17091709
send_entity(path, data, initheader, dest, Patch, &block)
17101710
end
17111711

1712-
def put(path, data, initheader = nil) #:nodoc:
1712+
# Sends a PUT request to the server;
1713+
# returns an instance of a subclass of Net::HTTPResponse.
1714+
#
1715+
# The request is based on the Net::HTTP::Put object
1716+
# created from string +path+, string +data+, and initial headers hash +initheader+.
1717+
#
1718+
# data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
1719+
# http.put('/todos/1', data) # => #<Net::HTTPOK 200 OK readbody=true>
1720+
#
1721+
def put(path, data, initheader = nil)
17131722
request(Put.new(path, initheader), data)
17141723
end
17151724

1716-
# Sends a PROPPATCH request to the +path+ and gets a response,
1717-
# as an HTTPResponse object.
1725+
# Sends a PROPPATCH request to the server;
1726+
# returns an instance of a subclass of Net::HTTPResponse.
1727+
#
1728+
# The request is based on the Net::HTTP::Proppatch object
1729+
# created from string +path+, string +body+, and initial headers hash +initheader+.
1730+
#
1731+
# data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
1732+
# http.proppatch('/todos/1', data)
1733+
#
17181734
def proppatch(path, body, initheader = nil)
17191735
request(Proppatch.new(path, initheader), body)
17201736
end
17211737

1722-
# Sends a LOCK request to the +path+ and gets a response,
1723-
# as an HTTPResponse object.
1738+
# Sends a LOCK request to the server;
1739+
# returns an instance of a subclass of Net::HTTPResponse.
1740+
#
1741+
# The request is based on the Net::HTTP::Lock object
1742+
# created from string +path+, string +body+, and initial headers hash +initheader+.
1743+
#
1744+
# data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
1745+
# http.lock('/todos/1', data)
1746+
#
17241747
def lock(path, body, initheader = nil)
17251748
request(Lock.new(path, initheader), body)
17261749
end
17271750

1728-
# Sends a UNLOCK request to the +path+ and gets a response,
1729-
# as an HTTPResponse object.
1751+
# Sends an UNLOCK request to the server;
1752+
# returns an instance of a subclass of Net::HTTPResponse.
1753+
#
1754+
# The request is based on the Net::HTTP::Unlock object
1755+
# created from string +path+, string +body+, and initial headers hash +initheader+.
1756+
#
1757+
# data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
1758+
# http.unlock('/todos/1', data)
1759+
#
17301760
def unlock(path, body, initheader = nil)
17311761
request(Unlock.new(path, initheader), body)
17321762
end
17331763

1734-
# Sends a OPTIONS request to the +path+ and gets a response,
1735-
# as an HTTPResponse object.
1764+
# Sends an Options request to the server;
1765+
# returns an instance of a subclass of Net::HTTPResponse.
1766+
#
1767+
# The request is based on the Net::HTTP::Options object
1768+
# created from string +path+ and initial headers hash +initheader+.
1769+
#
1770+
# http.options('/')
1771+
#
17361772
def options(path, initheader = nil)
17371773
request(Options.new(path, initheader))
17381774
end
17391775

1740-
# Sends a PROPFIND request to the +path+ and gets a response,
1741-
# as an HTTPResponse object.
1776+
# Sends a PROPFIND request to the server;
1777+
# returns an instance of a subclass of Net::HTTPResponse.
1778+
#
1779+
# The request is based on the Net::HTTP::Propfind object
1780+
# created from string +path+, string +body+, and initial headers hash +initheader+.
1781+
#
1782+
# data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
1783+
# http.propfind('/todos/1', data)
1784+
#
17421785
def propfind(path, body = nil, initheader = {'Depth' => '0'})
17431786
request(Propfind.new(path, initheader), body)
17441787
end
17451788

1746-
# Sends a DELETE request to the +path+ and gets a response,
1747-
# as an HTTPResponse object.
1789+
# Sends a DELETE request to the server;
1790+
# returns an instance of a subclass of Net::HTTPResponse.
1791+
#
1792+
# The request is based on the Net::HTTP::Delete object
1793+
# created from string +path+ and initial headers hash +initheader+.
1794+
#
1795+
# http.delete('/todos/1')
1796+
#
17481797
def delete(path, initheader = {'Depth' => 'Infinity'})
17491798
request(Delete.new(path, initheader))
17501799
end
17511800

1752-
# Sends a MOVE request to the +path+ and gets a response,
1753-
# as an HTTPResponse object.
1801+
# Sends a MOVE request to the server;
1802+
# returns an instance of a subclass of Net::HTTPResponse.
1803+
#
1804+
# The request is based on the Net::HTTP::Move object
1805+
# created from string +path+ and initial headers hash +initheader+.
1806+
#
1807+
# http.move('/todos/1')
1808+
#
17541809
def move(path, initheader = nil)
17551810
request(Move.new(path, initheader))
17561811
end
17571812

1758-
# Sends a COPY request to the +path+ and gets a response,
1759-
# as an HTTPResponse object.
1813+
# Sends a COPY request to the server;
1814+
# returns an instance of a subclass of Net::HTTPResponse.
1815+
#
1816+
# The request is based on the Net::HTTP::Copy object
1817+
# created from string +path+ and initial headers hash +initheader+.
1818+
#
1819+
# http.copy('/todos/1')
1820+
#
17601821
def copy(path, initheader = nil)
17611822
request(Copy.new(path, initheader))
17621823
end
17631824

1764-
# Sends a MKCOL request to the +path+ and gets a response,
1765-
# as an HTTPResponse object.
1825+
# Sends a MKCOL request to the server;
1826+
# returns an instance of a subclass of Net::HTTPResponse.
1827+
#
1828+
# The request is based on the Net::HTTP::Mkcol object
1829+
# created from string +path+, string +body+, and initial headers hash +initheader+.
1830+
#
1831+
# data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
1832+
# http.mkcol('/todos/1', data)
1833+
#
17661834
def mkcol(path, body = nil, initheader = nil)
17671835
request(Mkcol.new(path, initheader), body)
17681836
end
17691837

1770-
# Sends a TRACE request to the +path+ and gets a response,
1771-
# as an HTTPResponse object.
1838+
# Sends a TRACE request to the server;
1839+
# returns an instance of a subclass of Net::HTTPResponse.
1840+
#
1841+
# The request is based on the Net::HTTP::Trace object
1842+
# created from string +path+ and initial headers hash +initheader+.
1843+
#
1844+
# http.trace('/todos/1')
1845+
#
17721846
def trace(path, initheader = nil)
17731847
request(Trace.new(path, initheader))
17741848
end

0 commit comments

Comments
 (0)