43件ヒット
[1-43件を表示]
(0.039秒)
種類
- ライブラリ (36)
- インスタンスメソッド (7)
ライブラリ
- ビルトイン (7)
クラス
- Method (7)
キーワード
- irb (12)
-
rexml
/ document (12) -
rexml
/ parsers / ultralightparser (12)
検索結果
-
Method
# >>(callable) -> Proc (18124.0) -
self と引数を合成した Proc を返します。
...d(:f) >> method(:g)).call(3) # => 18
//}
//emlist[call を定義したオブジェクトを渡す例][ruby]{
class WordScanner
def self.call(str)
str.scan(/\w+/)
end
end
File.write('testfile', <<~TEXT)
Hello, World!
Hello, Ruby!
TEXT
pipeline = File.method(:read) >> WordScanner >> met......hod(:pp)
pipeline.call('testfile') # => ["Hello", "World", "Hello", "Ruby"]
//}
@see Proc#<<, Proc#>>... -
rexml
/ document (108.0) -
DOM スタイルの XML パーサ。
...以下のプログラムではブックマークの XML からデータを取り出します。
//emlist[][ruby]{
require 'rexml/document'
require 'pp'
Bookmark = Struct.new(:href, :title, :desc)
doc = REXML::Document.new(<<XML)
<?xml version="1.0" encoding="UTF-8" ?>
<xbel version="1.0">
<book......ef, title, desc)
end
pp bookmarks
# >> [#<struct Bookmark
# >> href="http://www.ruby-lang.org/ja/",
# >> title="オブジェクト指向スクリプト言語 Ruby",
# >> desc="Rubyの公式サイト">,
# >> #<struct Bookmark
# >> href="http://rurema.clear-code.com/",
# >> title="最速Rub......まサーチ",
# >> desc="Rubyリファレンスマニュアルを全文検索できる。\nとても便利。\n ">,
# >> #<struct Bookmark
# >> href="https://github.com/rurema/bitclust",
# >> title="rurema/bitclust · GitHub",
# >> desc=nil>,
# >> #<struct Bookmark
# >> href="https:/... -
rexml
/ parsers / ultralightparser (90.0) -
パース結果を配列で作られた木構造により返すパーサ。
...で、pp の表示では省略されています。
//emlist[][ruby]{
require 'rexml/parsers/ultralightparser'
require 'pp'
parser = REXML::Parsers::UltraLightParser.new(<<XML)
<?xml version="1.0" encoding="UTF-8" ?>
<root>
<a n="1">xyz</a>
<b m="2" />
</root>
XML
pp parser.parse
# >> [[:xmldec......TF-8", nil],
# >> [:text, "\n"],
# >> [:start_element,
# >> [...],
# >> "root",
# >> {},
# >> [:text, "\n "],
# >> [:start_element, [...], "a", {"n"=>"1"}, [:text, "xyz"]],
# >> [:text, "\n "],
# >> [:start_element, [...], "b", {"m"=>"2"}],
# >> [:text, "\n"]],
# >> [:text, "\n"... -
irb (18.0)
-
irb は Interactive Ruby の略です。 irb を使うと、Ruby の式を標準入力から簡単に入力・実行することができます。
...//emlist{
irb(main):001:0> help
Enter the method name you want to look up.
You can use tab to autocomplete.
Enter a blank line to exit.
>> String#match
String#match
(from ruby core)
------------------------------------------------------------------------------
str.match(pa......raw
出力結果を to_s したものを表示します。
: true, :p, :inspect
出力結果を inspect したものを表示します。
: :pp, :pretty_inspect
出力結果を pretty_inspect したものを表示します。
: :yaml, :YAML
出力結果を YAML 形式にしたもの......--- :foo
また、irb の起動時に --inspect オプションを指定する事でも同様の設定を行
えます。
$ irb --inspect [raw|p|pp|yaml|marshal|...]
上記以外にも独自の出力方式を追加する事ができます。詳しくは
IRB::Inspector.def_inspector を参照し...