178件ヒット
[1-100件を表示]
(0.067秒)
別のキーワード
ライブラリ
- ビルトイン (57)
- csv (42)
-
fiddle
/ import (24) -
json
/ add / struct (12) - ostruct (19)
-
rexml
/ document (24)
クラス
- Array (21)
- CSV (36)
-
CSV
:: Row (6) - OpenStruct (19)
-
REXML
:: Instruction (24) -
RubyVM
:: InstructionSequence (24) - String (12)
- Struct (12)
モジュール
-
Fiddle
:: Importer (24)
キーワード
- content (12)
- convert (36)
- deconstruct (3)
-
deconstruct
_ keys (3) -
first
_ lineno (12) - pack (21)
- target (12)
-
to
_ a (12) -
to
_ h (19) -
to
_ json (12) - union (12)
- unpack (12)
検索結果
先頭5件
-
RubyVM
:: InstructionSequence # to _ a -> Array (26019.0) -
self の情報を 14 要素の配列にして返します。
...ます。
命令シーケンスを以下の情報で表します。
: magic
データフォーマットを示す文字列。常に
"YARVInstructionSequence/SimpleDataFormat"。
: major_version
命令シーケンスのメジャーバージョン。
: minor_version
命令シーケンス......配列。
: args
引数の指定が必須のメソッド、ブロックの引数の個数。あるいは以下のよう
な配列。
[required_argc, [optional_arg_labels, ...],
splat_index, post_splat_argc, post_splat_index,
block_index, simple]
より詳細な情報につい......を構成する命令とオペランドの配列の配列。
//emlist[例][ruby]{
require 'pp'
iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
pp iseq.to_a
# ※ Ruby 2.5.0 での実行結果
# => ["YARVInstructionSequence/SimpleDataFormat",
# 2,
# 0,
# 1,
# {:arg_size=>0, :local_size=>... -
RubyVM
:: InstructionSequence # first _ lineno -> Integer (26007.0) -
self が表す命令シーケンスの 1 行目の行番号を返します。
...の 1 行目の行番号を返します。
例1:irb で実行した場合
RubyVM::InstructionSequence.compile('num = 1 + 2').first_lineno
# => 1
例2:
# /tmp/method.rb
require "foo-library"
def foo
p :foo
end
RubyVM::InstructionSequence.of(method(:foo)).first_lineno
# => 2... -
Fiddle
:: Importer # struct(signature) -> Class (18142.0) -
C の構造体型に対応する Ruby のクラスを構築して返します。
...C の構造体型に対応する Ruby のクラスを構築して返します。
構造体の各要素は C と似せた表記ができます。そしてそれを
配列で signature に渡してデータを定義します。例えば C における
struct timeval {
long tv_sec;
long tv_u......sec;
};
という構造体型に対応して
Timeval = struct(["long tv_sec", "long tv_usec"])
として構造体に対応するクラスを生成します。
このメソッドが返すクラスには以下のメソッドが定義されています
* クラスメソッド malloc
* initiali......ンバへのアクセサ
返されるクラスは Fiddle::CStruct を継承しています。詳しくは
そちらを参照してください。
@param signature 構造体の各要素を文字列で表現したものの配列
require 'fiddle/import'
module M
extend Fiddle::Importer... -
Struct
# to _ json(*args) -> String (9019.0) -
自身を JSON 形式の文字列に変換して返します。
...す。
@param args 引数はそのまま JSON::Generator::GeneratorMethods::Hash#to_json に渡されます。
//emlist[例][ruby]{
require "json/add/core"
Person = Struct.new(:name, :age)
Person.new("tanaka", 29).to_json # => "{\"json_class\":\"Person\",\"v\":[\"tanaka\",29]}"
//}
@see JSON::Ge... -
CSV
:: Row # deconstruct -> [object] (6113.0) -
パターンマッチに使用する行の値の配列を返します。
...パターンマッチに使用する行の値の配列を返します。
//emlist[例][ruby]{
require "csv"
row = CSV::Row.new(["header1", "header2", "header3"], [1, 2, 3])
case row
in [2.., 2.., 2..]
puts "all 2 or more"
in [...2, 2.., 2..]
puts "first column is less than 2, and rest columns... -
CSV
:: Row # deconstruct _ keys(keys) -> Hash (6113.0) -
パターンマッチに使用するヘッダの名前と値の Hash を返します。
...使用するヘッダの名前の配列を指定します。nil の場合は全てをパターンマッチに使用します。
//emlist[例][ruby]{
require "csv"
row = CSV::Row.new([:header1, :header2, :header3], [1, 2, 3])
case row
in { header1: 2.., header2: 2.., header3: 2.. }
puts "all 2 or... -
OpenStruct
# to _ h -> { Symbol => object } (3013.0) -
self を各要素の名前をキー(Symbol)、要素が値のハッシュに変換して返 します。
...self を各要素の名前をキー(Symbol)、要素が値のハッシュに変換して返
します。
//emlist[例][ruby]{
require 'ostruct'
data = OpenStruct.new("country" => "Australia", :capital => "Canberra")
data.to_h # => {:country => "Australia", :capital => "Canberra" }
//}......ックを指定すると各ペアでブロックを呼び出し、
その結果をペアとして使います。
//emlist[例][ruby]{
require 'ostruct'
data = OpenStruct.new("country" => "Australia", :capital => "Canberra")
data.to_h # => {:country => "Australia", :capital => "Canberra" }
data.to... -
OpenStruct
# to _ h {|name , value| block } -> Hash (3013.0) -
self を各要素の名前をキー(Symbol)、要素が値のハッシュに変換して返 します。
...ックを指定すると各ペアでブロックを呼び出し、
その結果をペアとして使います。
//emlist[例][ruby]{
require 'ostruct'
data = OpenStruct.new("country" => "Australia", :capital => "Canberra")
data.to_h # => {:country => "Australia", :capital => "Canberra" }
data.to... -
REXML
:: Instruction # content -> String | nil (3013.0) -
XML 処理命令の内容を返します。
...XML 処理命令の内容を返します。
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/css" href="style.css"?>
<?foobar?>
<root />
EOS
doc[2] # => <?p-i xml-stylesheet ...?>
doc[2].target # => "xml-... -
REXML
:: Instruction # target -> String (3013.0) -
XML 処理命令のターゲットを返します。
...XML 処理命令のターゲットを返します。
//emlist[][ruby]{
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/css" href="style.css"?>
<root />
EOS
doc[2] # => <?p-i xml-stylesheet ...?>
doc[2].target # => "xml-st... -
Array
# pack(template) -> String (613.0) -
配列の内容を template で指定された文字列にしたがって、 バイナリとしてパックした文字列を返します。
...いことに注意してください。
buffer のサイズ(capacity)が足りなければ、packはメモリを確保します。
//emlist[例][ruby]{
['!'].pack('@1a', buffer: 'abc') # => "a!"
['!'].pack('@5a', buffer: 'abc') # => "abc\u0000\u0000!"
//}
@param template 自身のバイナリと......][ruby]{
["abc"].pack("a") # => "a"
["abc"].pack("a*") # => "abc"
["abc"].pack("a4") # => "abc\x00"
"abc\0".unpack("a4") # => ["abc\x00"]
"abc ".unpack("a4") # => ["abc "]
//}
: A
ASCII文字列(スペースを詰める/後続するヌル文字やスペースを削除)
//emlist[][ruby]{......ist[][ruby]{
["abc"].pack("Z") # => "a"
["abc"].pack("Z*") # => "abc\x00"
["abc"].pack("Z5") # => "abc\x00\x00"
"abc\0".unpack("Z4") # => ["abc"]
"abc ".unpack("Z4") # => ["abc "]
//}
: b
ビットストリング(各バイトごとに下位ビットから上位ビット)
//emlist[][ruby]{
"\x...