215件ヒット
[1-100件を表示]
(0.160秒)
ライブラリ
- ビルトイン (138)
- csv (33)
- mkmf (22)
-
rdoc
/ markup (11) - zlib (11)
クラス
- BasicObject (22)
- CSV (33)
- Class (11)
-
Encoding
:: Converter (11) - Module (11)
- Object (22)
- Proc (6)
-
RDoc
:: Markup (11) -
RubyVM
:: InstructionSequence (44) -
Thread
:: Backtrace :: Location (11) -
Zlib
:: GzipWriter (11)
モジュール
- Kernel (22)
キーワード
- ! (11)
- != (11)
- << (28)
- === (11)
-
absolute
_ path (11) -
add
_ row (11) -
add
_ special (11) -
base
_ label (22) - disassemble (11)
- inherited (11)
- initialize (11)
-
insert
_ output (11) - label (11)
-
try
_ cpp (22) -
undef
_ method (11)
検索結果
先頭5件
-
CSV
# puts(row) -> self (18208.0) -
自身に row を追加します。
...SV::Row#fields の値
のみが追加されます。
//emlist[例 配列を指定][ruby]{
require "csv"
File.write("test.csv", <<CSV)
id,first name,last name,age
1,taro,tanaka,20
2,jiro,suzuki,18
3,ami,sato,19
4,yumi,adachi,21
CSV
CSV.open("test.csv", "a") do |csv|
csv.puts(["5", "sab......"])
end
print File.read("test.csv")
# => id,first name,last name,age
# 1,taro,tanaka,20
# 2,jiro,suzuki,18
# 3,ami,sato,19
# 4,yumi,adachi,21
# 5,saburo,kondo,34
//}
//emlist[例 CSV::Row を指定][ruby]{
require "csv"
File.write("test.csv", <<CSV)
id,first name,last name,age
1,ta......i,21
CSV
CSV.open("test.csv", "a") do |csv|
row = CSV::Row.new(["id", "first name", "last name", "age"], ["5", "saburo", "kondo", "34"])
csv.add_row(row)
end
print File.read("test.csv")
# => "id", first name,last name,age
# 1,taro,tanaka,20
# 2,jiro,suzuki,18
# 3,ami,sato,19
# 4,yum... -
Zlib
:: GzipWriter # <<(str) -> self (9207.0) -
str を出力します。str が文字列でない場合は to_s を用いて 文字列に変換します。
...ェクトを与えます。
require 'zlib'
filename='hoge1.gz'
fw = File.open(filename, "w")
Zlib::GzipWriter.wrap(fw, Zlib::BEST_COMPRESSION){|gz|
gz << "hoge" << "fuga"
}
fr = File.open(filename)
Zlib::GzipReader.wrap(fr){|gz|
puts gz.read
}
#=> hogefuga
@see IO#<<... -
CSV
# <<(row) -> self (6208.0) -
自身に row を追加します。
...SV::Row#fields の値
のみが追加されます。
//emlist[例 配列を指定][ruby]{
require "csv"
File.write("test.csv", <<CSV)
id,first name,last name,age
1,taro,tanaka,20
2,jiro,suzuki,18
3,ami,sato,19
4,yumi,adachi,21
CSV
CSV.open("test.csv", "a") do |csv|
csv.puts(["5", "sab......"])
end
print File.read("test.csv")
# => id,first name,last name,age
# 1,taro,tanaka,20
# 2,jiro,suzuki,18
# 3,ami,sato,19
# 4,yumi,adachi,21
# 5,saburo,kondo,34
//}
//emlist[例 CSV::Row を指定][ruby]{
require "csv"
File.write("test.csv", <<CSV)
id,first name,last name,age
1,ta......i,21
CSV
CSV.open("test.csv", "a") do |csv|
row = CSV::Row.new(["id", "first name", "last name", "age"], ["5", "saburo", "kondo", "34"])
csv.add_row(row)
end
print File.read("test.csv")
# => "id", first name,last name,age
# 1,taro,tanaka,20
# 2,jiro,suzuki,18
# 3,ami,sato,19
# 4,yum... -
Proc
# <<(callable) -> Proc (6207.0) -
self と引数を合成した Proc を返します。
...self と引数を合成した Proc を返します。
戻り値の Proc は可変長の引数を受け取ります。
戻り値の Proc を呼び出すと、まず受け取った引数を callable に渡して呼び出し、
その戻り値を self に渡して呼び出した結果を返します......aram callable Proc、Method、もしくは任意の call メソッドを持ったオブジェクト。
//emlist[例][ruby]{
f = proc { |x| x * x }
g = proc { |x| x + x }
# (3 + 3) * (3 + 3)
p (f << g).call(3) # => 36
//}
//emlist[call を定義したオブジェクトを渡す例][ruby]{
class Wo......anner
def self.call(str)
str.scan(/\w+/)
end
end
File.write('testfile', <<~TEXT)
Hello, World!
Hello, Ruby!
TEXT
pipeline = proc { |data| puts "word count: #{data.size}" } << WordScanner << File.method(:read)
pipeline.call('testfile') # => word count: 4
//}
@see Method#<<, Method#>>... -
Object
# initialize(*args , &block) -> object (6119.0) -
ユーザ定義クラスのオブジェクト初期化メソッド。
...。
このメソッドは Class#new から新しく生成されたオブ
ジェクトの初期化のために呼び出されます。他の言語のコンストラクタに相当します。
デフォルトの動作ではなにもしません。
initialize には
Class#new に与えられた引数......initialize という名前のメソッドは自動的に private に設定され
ます。
@param args 初期化時の引数です。
@param block 初期化時のブロック引数です。必須ではありません。
//emlist[][ruby]{
class Foo
def initialize name
puts "initialize Foo"......@name = name
end
end
class Bar < Foo
def initialize name, pass
puts "initialize Bar"
super name
@pass = pass
end
end
it = Bar.new('myname','0500')
p it
#=> initialize Bar
# initialize Foo
# #<Bar:0x2b68f08 @name="myname", @pass="0500">
//}
@see Class#new... -
RubyVM
:: InstructionSequence # base _ label -> String (6119.0) -
self が表す命令シーケンスの基本ラベルを返します。
...self が表す命令シーケンスの基本ラベルを返します。
例1:irb で実行した場合
iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
# => <RubyVM::InstructionSequence:<compiled>@<compiled>>
iseq.base_label
# => "<compiled>"
例2: RubyVM::InstructionSequence.co......mpile_file を使用した場合
# /tmp/method.rb
def hello
puts "hello, world"
end
# irb
> iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb')
> iseq.base_label # => "<main>"
例3:
# /tmp/method2.rb
def hello
puts "hello, world"
end
RubyVM::Instruction......Sequence.of(method(:hello)).base_label
# => "hello"
@see RubyVM::InstructionSequence#label... -
RubyVM
:: InstructionSequence # label -> String (6119.0) -
self が表す命令シーケンスのラベルを返します。通常、メソッド名、クラス名、 モジュール名などで構成されます。
...self が表す命令シーケンスのラベルを返します。通常、メソッド名、クラス名、
モジュール名などで構成されます。
トップレベルでは "<main>" を返します。self を文字列から作成していた場合
は "<compiled>" を返します。
例1......pile('num = 1 + 2')
# => <RubyVM::InstructionSequence:<compiled>@<compiled>>
iseq.label
# => "<compiled>"
例2: RubyVM::InstructionSequence.compile_file を使用した場合
# /tmp/method.rb
def hello
puts "hello, world"
end
# irb
> iseq = RubyVM::InstructionSequence.compile_......file('/tmp/method.rb')
> iseq.label # => "<main>"
例3:
# /tmp/method2.rb
def hello
puts "hello, world"
end
RubyVM::InstructionSequence.of(method(:hello)).label
# => "hello"
@see RubyVM::InstructionSequence#base_label... -
RDoc
:: Markup # add _ special(pattern , name) -> () (6113.0) -
pattern で指定した正規表現にマッチする文字列をフォーマットの対象にしま す。
...、SM::SimpleMarkup#add_word_pair、
SM::SimpleMarkup#add_html でフォーマットできないものに対して使用
します。
@param pattern 正規表現を指定します。
@param name SM::ToHtml などのフォーマッタに識別させる時の名前を
Symbol で指定し......simple_markup'
require 'rdoc/markup/simple_markup/to_html'
class WikiHtml < SM::ToHtml
def handle_special_WIKIWORD(special)
"<font color=red>" + special.text + "</font>"
end
end
m = SM::SimpleMarkup.new
m.add_special(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
h = WikiHtml.new......puts m.convert(input_string, h)
変換時に実際にフォーマットを行うには SM::ToHtml#accept_special_<name で指定した名前>
のように、フォーマッタ側でも操作を行う必要があります。... -
RubyVM
:: InstructionSequence # absolute _ path -> String | nil (6113.0) -
self が表す命令シーケンスの絶対パスを返します。
...self が表す命令シーケンスの絶対パスを返します。
self を文字列から作成していた場合は nil を返します。
例1:irb で実行した場合
iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
# => <RubyVM::InstructionSequence:<compiled>@<compiled>>
i......seq.absolute_path
# => nil
例2: RubyVM::InstructionSequence.compile_file を使用した場合
# /tmp/method.rb
def hello
puts "hello, world"
end
# irb
> iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb')
> iseq.absolute_path # => "/tmp/method.rb"
@see RubyVM::I... -
Thread
:: Backtrace :: Location # base _ label -> String (6113.0) -
self が表すフレームの基本ラベルを返します。通常、 Thread::Backtrace::Location#label から修飾を取り除いたもので構成 されます。
...self が表すフレームの基本ラベルを返します。通常、
Thread::Backtrace::Location#label から修飾を取り除いたもので構成
されます。
//emlist[例][ruby]{
# foo.rb
class Foo
attr_accessor :locations
def initialize(skip)
@locations = caller_locations(skip)......end
end
Foo.new(0..2).locations.map do |call|
puts call.base_label
end
# => initialize
# new
# <main>
//}
@see Thread::Backtrace::Location#label...