るりまサーチ (Ruby 2.4.0)

最速Rubyリファレンスマニュアル検索!
4件ヒット [1-4件を表示] (0.126秒)

別のキーワード

  1. optparse on
  2. optionparser on
  3. tracer on
  4. thread abort_on_exception
  5. thread abort_on_exception=

ライブラリ

モジュール

キーワード

検索結果

Net::HTTPHeader#content_type -> String|nil (72679.0)

"text/html" のような Content-Type を表す 文字列を返します。

"text/html" のような Content-Type を表す
文字列を返します。

Content-Type: ヘッダフィールドが存在しない場合には nil を返します。

//emlist[例][ruby]{
require 'net/http'

uri = URI.parse('http://www.example.com/comments.cgi?post=comment')
req = Net::HTTP::Post.new(uri.request_uri)
req.content_type # => nil
req.content_type = 'multipart/for...

Net::HTTPHeader#content_type=(type) (36682.0)

type と params から Content-Type: ヘッダフィールドの 値を設定します。

type と params から Content-Type: ヘッダフィールドの
値を設定します。

@param type メディアタイプを文字列で指定します。
@param params パラメータ属性をハッシュで指定します。

//emlist[例][ruby]{
require 'net/http'

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.content_type # => ni...

Net::HTTPHeader#set_content_type(type, params = {}) (36682.0)

type と params から Content-Type: ヘッダフィールドの 値を設定します。

type と params から Content-Type: ヘッダフィールドの
値を設定します。

@param type メディアタイプを文字列で指定します。
@param params パラメータ属性をハッシュで指定します。

//emlist[例][ruby]{
require 'net/http'

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.content_type # => ni...

OpenURI::OpenRead#read(options = {}) -> String (340.0)

自身が表す内容を読み込んで文字列として返します。 self.open(options={}) {|io| io.read } と同じです。 このメソッドによって返される文字列は OpenURI::Meta によって extend されています。

自身が表す内容を読み込んで文字列として返します。
self.open(options={}) {|io| io.read } と同じです。
このメソッドによって返される文字列は OpenURI::Meta
によって extend されています。

@param options ハッシュを与えます。

require 'open-uri'
uri = URI.parse('http://www.example.com/')
str = uri.read
p str.is_a?(OpenURI::Meta) # => true
p str.content_type