るりまサーチ

最速Rubyリファレンスマニュアル検索!
152件ヒット [1-100件を表示] (0.030秒)
トップページ > クエリ:<<[x] > 種類:クラス[x]

別のキーワード

  1. _builtin <<
  2. csv <<
  3. openssl <<
  4. rexml/document <<
  5. zlib <<

ライブラリ

キーワード

検索結果

<< 1 2 > >>

CSV (43.0)

このクラスは CSV ファイルやデータに対する完全なインターフェイスを提供します。

...イルやデータに対する完全なインターフェイスを提供します。

=== 読み込み

//emlist[][ruby]{
require "csv"

csv_text = <<~CSV_TEXT
Ruby,1995
Rust,2010
CSV_TEXT

IO.write "sample.csv", csv_text

# ファイルから一行ずつ
CSV.foreach("sample.csv") do |row|
p r...
...き込み
CSV.open("path/to/file.csv", "wb") do |csv|
csv << ["row", "of", "CSV", "data"]
csv << ["another", "row"]
# ...
end

# 文字列へ書き込み
csv_string = CSV.generate do |csv|
csv << ["row", "of", "CSV", "data"]
csv << ["another", "row"]
# ...
end
//}

=== 一行変換

//em...
...ット

//emlist[][ruby]{
require 'csv'

CSV { |csv_out| csv_out << %w{my data here} } # to $stdout
CSV(csv = "") { |csv_str| csv_str << %w{my data here} } # to a String
CSV($stderr) { |csv_err| csv_err << %w{my data here} } # to $stderr
//}

=== CSV と文字エンコーディ...

OpenSSL::Cipher (25.0)

共通鍵暗号のために抽象化されたインターフェースを提供するクラスです。

..._data << enc.update(data)
encrypted_data << enc.final

p encrypted_data

# 復号化器を作成する
dec = OpenSSL::Cipher.new("AES-256-CBC")
dec.decrypt

# 鍵とIVを設定する
dec.key = key
dec.iv = iv

# 復号化する
decrypted_data = ""
decrypted_data << dec....
...update(encrypted_data)
decrypted_data << dec.final

p decrypted_data...

Ripper::Filter (25.0)

イベントドリブンスタイルで Ruby プログラムを加工するためのクラスです。

...e 'ripper'
require 'cgi'

class
Ruby2HTML < Ripper::Filter
def on_default(event, tok, f)
f << CGI.escapeHTML(tok)
end

def on_comment(tok, f)
f << %Q[<span class="comment">#{CGI.escapeHTML(tok)}</span>]
end

def on_tstring_beg(tok, f)
f << %Q[<span class="string">#{CGI.escapeHT...
...ML(tok)}]
end

def on_tstring_end(tok, f)
f << %Q[#{CGI.escapeHTML(tok)}</span>]
end
end

Ruby2HTML.new(ARGF).parse('')
//}

Ruby プログラムを解析して、Ripper::SCANNER_EVENTS にあるスキャナ
イベントを実行します。イベントはプログラムに書いた順番...

Psych::Visitors::YAMLTree (13.0)

Ruby オブジェクトから YAML の AST を構築するためのクラスです。

...ェクトから YAML の AST を構築するためのクラスです。

=== 例
builder = Psych::Visitors::YAMLTree.new
builder << { :foo => 'bar' }
builder << ["baz", "bazbaz"]
builder.tree # => #<Psych::Nodes::Stream ... > A stream containing two documents
puts tree.to_yaml
# =>
# -...

ERB (7.0)

eRuby スクリプトを処理するクラス。

...よって生
成される文字列のエンコーディングを指定することができます。

# -*- coding: UTF-8 -*-
require 'erb'

template = ERB.new <<EOF
<%#-*- coding: Big5 -*-%>
__ENCODING__ is <%= __ENCODING__ %>.
EOF
puts template.result # => __ENCODING__ is Big5...

絞り込み条件を変える

FrozenError (7.0)

Object#freezeされたオブジェクトを変更しようとした時に発生します。

...Object#freezeされたオブジェクトを変更しようとした時に発生します。


//emlist[例][ruby]{
[1, 2, 3].freeze << 4 # FrozenError: can't modify frozen Array
//}...

Numeric (7.0)

数値を表す抽象クラスです。Integer や Float などの数値クラス は Numeric のサブクラスとして実装されています。

...um Float Rational Complex
-------------------------------------------------------------------------------------------
<<
| - - o o - - -
<= | - - o...
...d
//}

また、任意桁の切上げ、切捨て、四捨五入を行うメソッドは以下のように
定義できます。

//emlist[][ruby]{
class
Numeric
def roundup(d=0)
x = 10**d
if self > 0
self.quo(x).ceil * x
else
self.quo(x).floor * x
end
end

def roun...
...Numeric Integer Float Rational Complex
--------------------------------------------------------------------------------
<<
| - o - - -
<= | - o o - -...

REXML::Formatters::Default (7.0)

XMLドキュメントを(文字列として)出力するクラスです。

...正せずにそのまま出力します。

//emlist[][ruby]{
require 'rexml/document'
require 'rexml/formatters/default'
doc = REXML::Document.new <<EOS
<root>
<children>
<grandchildren/>
</children>
</root>
EOS

default_formatter = REXML::Formatters::Default.new
output = StringIO.new
default_for...

REXML::Formatters::Pretty (7.0)

XMLドキュメントを(文字列として)見た目良く出力するクラスです。

...行や空白を修正して出力します。

//emlist[][ruby]{
require 'rexml/document'
require 'rexml/formatters/pretty'
doc = REXML::Document.new <<EOS
<root>
<children>
<grandchildren foo='bar'/>
</children>
</root>
EOS

pretty_formatter = REXML::Formatters::Pretty.new
output = StringIO.new
p...
<< 1 2 > >>