D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Net
/
HTTPHeader
/
Filename :
fetch-i.ri
back
Copy
U:RDoc::AnyMethod[iI" fetch:ETI"Net::HTTPHeader#fetch;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [ I"DWith a block, returns the string value for +key+ if it exists; ;TI"/otherwise returns the value of the block; ;TI" ignores the +default_val+; ;TI"3see {Fields}[rdoc-ref:Net::HTTPHeader@Fields]:;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [I"8res = Net::HTTP.get_response(hostname, '/todos/1') ;TI" ;TI"'# Field exists; block not called. ;TI"(res.fetch('Connection') do |value| ;TI" fail 'Cannot happen' ;TI"end # => "keep-alive" ;TI" ;TI"+# Field does not exist; block called. ;TI"$res.fetch('Nosuch') do |value| ;TI" value.downcase ;TI"end # => "nosuch" ;T:@format0o; ; [I"EWith no block, returns the string value for +key+ if it exists; ;TI"7otherwise, returns +default_val+ if it was given; ;TI"#otherwise raises an exception:;T@o;; [I"6res.fetch('Connection', 'Foo') # => "keep-alive" ;TI"/res.fetch('Nosuch', 'Foo') # => "Foo" ;TI"6res.fetch('Nosuch') # Raises KeyError.;T; 0: @fileI"lib/net/http/header.rb;T:0@omit_headings_from_table_of_contents_below0I"pfetch(key, default_val = nil) {|key| ... } -> object fetch(key, default_val = nil) -> value or default_val ;TI"key;T[ I"(key, *args);T@)FI"HTTPHeader;TcRDoc::NormalModule00