種類
- インスタンスメソッド (44)
- 文書 (33)
- ライブラリ (22)
ライブラリ
- csv (44)
クラス
- CSV (33)
-
CSV
:: FieldInfo (11)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) - rdoc (11)
- rss (11)
-
ruby 1
. 6 feature (11) -
ruby 1
. 9 feature (11)
検索結果
先頭5件
-
CSV
# convert {|field , field _ info| . . . } (18133.0) -
引数 name で指定した変換器かブロックに各フィールドを渡して文字列から別 のオブジェクトへと変換します。
...ールドを渡して文字列から別
のオブジェクトへと変換します。
引数 name を指定した場合は、組み込みの CSV::Converters を変換器
として利用するために使います。また、独自の変換器を追加することもできま
す。
ブロックパ......ばなりません。
@param name 変換器の名前を指定します。
//emlist[例 name で Converter を指定][ruby]{
require "csv"
csv = CSV.new("date1,date2\n2018-07-09,2018-07-10")
csv.convert(:date)
csv.read # => 2018-07-09 ((2458309j,0s,0n),+0s,2299161j)>, #<Date: 2018-07-10 ((2458310......-07-09,2018-07-10", headers: true)
csv.convert do |field,field_info|
p field
p field_info
Date.parse(field)
end
p csv.first
# => "2018-07-09"
# => <struct CSV::FieldInfo index=0, line=2, header="date1">
# => "2018-07-10"
# => #<struct CSV::FieldInfo index=1, line=2, header="date2">
# => #<CSV... -
CSV
# convert {|field| . . . } (18133.0) -
引数 name で指定した変換器かブロックに各フィールドを渡して文字列から別 のオブジェクトへと変換します。
...ールドを渡して文字列から別
のオブジェクトへと変換します。
引数 name を指定した場合は、組み込みの CSV::Converters を変換器
として利用するために使います。また、独自の変換器を追加することもできま
す。
ブロックパ......ばなりません。
@param name 変換器の名前を指定します。
//emlist[例 name で Converter を指定][ruby]{
require "csv"
csv = CSV.new("date1,date2\n2018-07-09,2018-07-10")
csv.convert(:date)
csv.read # => 2018-07-09 ((2458309j,0s,0n),+0s,2299161j)>, #<Date: 2018-07-10 ((2458310......-07-09,2018-07-10", headers: true)
csv.convert do |field,field_info|
p field
p field_info
Date.parse(field)
end
p csv.first
# => "2018-07-09"
# => <struct CSV::FieldInfo index=0, line=2, header="date1">
# => "2018-07-10"
# => #<struct CSV::FieldInfo index=1, line=2, header="date2">
# => #<CSV... -
CSV
# convert(name) (18133.0) -
引数 name で指定した変換器かブロックに各フィールドを渡して文字列から別 のオブジェクトへと変換します。
...ールドを渡して文字列から別
のオブジェクトへと変換します。
引数 name を指定した場合は、組み込みの CSV::Converters を変換器
として利用するために使います。また、独自の変換器を追加することもできま
す。
ブロックパ......ばなりません。
@param name 変換器の名前を指定します。
//emlist[例 name で Converter を指定][ruby]{
require "csv"
csv = CSV.new("date1,date2\n2018-07-09,2018-07-10")
csv.convert(:date)
csv.read # => 2018-07-09 ((2458309j,0s,0n),+0s,2299161j)>, #<Date: 2018-07-10 ((2458310......-07-09,2018-07-10", headers: true)
csv.convert do |field,field_info|
p field
p field_info
Date.parse(field)
end
p csv.first
# => "2018-07-09"
# => <struct CSV::FieldInfo index=0, line=2, header="date1">
# => "2018-07-10"
# => #<struct CSV::FieldInfo index=1, line=2, header="date2">
# => #<CSV... -
CSV
:: FieldInfo # index -> Integer (18113.0) -
行内で何番目のフィールドかわかるゼロベースのインデックスを返します。
...返します。
//emlist[例][ruby]{
require 'csv'
csv = CSV.new("date1,date2\n2018-07-09,2018-07-10", headers: true)
csv.convert do |field,field_info|
p field_info.index
Date.parse(field)
end
p csv.first
# => 0
# => 1
# => #<CSV::Row "date1":#<Date: 2018-07-09 ((2458309j,0s,0n),+0s,2299161j)... -
rss (108.0)
-
RSS を扱うためのライブラリです。
...xampleというサイトを
* http://example.com/index.rdfという名前のRSS 1.0
を生成するには以下のようにします.
require "rss"
rss = RSS::Maker.make("1.0") do |maker|
maker.channel.about = "http://example.com/index.rdf"
maker.channel.title = "Example"
make......ければ以下のようにします.
require "rss"
rss = RSS::Maker.make("1.0") do |maker|
maker.channel.about = "http://example.com/index.rdf"
maker.channel.title = "Example"
maker.channel.description = "Example Site"
maker.channel.link = "http://example.com/"
item = m......えて
扱うことにします。
def print_items(feed)
convert_to_rss10(feed).items.each do |item|
puts "#{item.title} : #{item.description}"
end
end
convert_to_rss10は以下のようになります。
def convert_to_rss10(feed)
feed.to_rss("1.0") do |maker|
maker... -
rdoc (30.0)
-
RDoc は Ruby のドキュメント生成を行うためのライブラリです。rdoc という ドキュメント生成のためのコマンドも含んでいます。
...the name of one or more output files. If multiple
files are present, the first is used as the index.
<tt>--quiet:</tt>:: do not output the names, sizes, byte counts,
index areas, or bit ratios of units as
they are processed.
====[a:headline] 見......トを書くと、この出力を上書
きできます。
def fred # :yields: index, position
...
yield line, address
上のようにすると、以下の出力になります。
fred() { |index, position| ... }
====[a:escape] エスケープ
マークアップは <tt> タグ......ction: を title で指定したものに上書きします。
//emlist{
# :category: Utility Methods
#
# CGI escapes +text+
def convert_string text
CGI.escapeHTML text
end
//}
title を省略した場合は、:section: を指定しなかった場合と同じように... -
ruby 1
. 9 feature (30.0) -
ruby 1.9 feature ruby version 1.9.0 は開発版です。 以下にあげる機能は将来削除されたり互換性のない仕様変更がなされるかもしれません。 1.9.1 以降は安定版です。 バグ修正がメインになります。
...)(7) # => 7
=== 2005-05-08
: Hash#hash [obsolete]
: Hash#eql? [obsolete]
削除
((<ruby-dev:26132>))
=== 2005-04-02
: ENV.key [new]
: ENV.index [obsolete]
((<ruby-dev:25974>))
=== 2005-03-09
: Ruby 2.0 ブロックローカル変数
((<URL:http://www.rubyist.net/~matz/20050309.html....../Maker [lib] [new]
((<Imageモジュール|URL:http://web.resource.org/rss/1.0/modules/image/>))のサポート
=== 2005-02-03
: RSS::Element#convert(value) [lib] [new]
valueのエンコーディングを変換するメソッドを公開。
valueのエンコーディングは要素の......$" に追加されるタイミングが load された後に変わりました。
((<ruby-list:40085>))
=== 2004-10-05
: Array#index {|x| ... } [new]
: Array#rindex {|x| ... } [new]
追加 ((<ruby-talk:113069>))
=== 2004-09-26
: Time#to_time [lib][new]
: Time#to_date [lib][new]
: Time#to_d... -
ruby 1
. 6 feature (24.0) -
ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。
...返していた
p "foo".slice!(5,10)
=> ruby 1.6.7 (2002-03-01) [i586-linux]
nil
-:2:in `slice!': index 5 out of string (IndexError)
from -:2
=> ruby 1.6.7 (2002-08-01) [i586-linux]
nil
nil
: 2002-07-05 String#spli......p foo["bar"] = "baz"
p foo
=> ruby 1.6.7 (2002-03-01) [i586-linux]
"baz"
"foo"
=> -:2:in `[]=': string not matched (IndexError)
from -:2
ruby 1.6.7 (2002-07-30) [i586-linux]
: 2002-06-03 sprintf()
"%d" で引数を整数にするときに、((<......対して例外が発生していました。
((<ruby-bugs-ja:PR#114>))
p(-1[10000000000])
=> -:1:in `[]': bignum too big to convert into `int' (RangeError)
from -:1
ruby 1.6.5 (2001-09-19) [i586-linux]
=> ruby 1.6.5 (2001-11-01) [i586-linux]... -
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (18.0) -
1.6.8から1.8.0への変更点(まとめ) * ((<1.6.8から1.8.0への変更点(まとめ)/インタプリタの変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたクラス/モジュール>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたメソッド>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加された定数>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張されたクラス/メソッド(互換性のある変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/変更されたクラス/メソッド(互換性のない変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/文法の変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/正規表現>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Marshal>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Windows 対応>)) * ((<1.6.8から1.8.0への変更点(まとめ)/廃止された(される予定の)機能>)) * ((<1.6.8から1.8.0への変更点(まとめ)/ライブラリ>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張ライブラリAPI>)) * ((<1.6.8から1.8.0への変更点(まとめ)/バグ修正>)) * ((<1.6.8から1.8.0への変更点(まとめ)/サポートプラットフォームの追加>))
...[new]
: ((<aStruct#values_at|Struct/values_at>)) [new]
ruby 1.6 の ((<indexes|Array/indexes>)) は、values_at というメソッド
名になりました(ruby 1.7 では block なし ((<select|Array/select>)) が
indexes の代わりでしたが、こちらも使用すると警告が出ま......映された上で obsolete)
# str =~ arg だけは、arg が文字列のとき、
# Regexp.compile(Regexp.quote(arg)) =~ str と等価な str.index(arg) が
# 実行されます(したがって、$~ は設定されません)。
$; の指定に正規表現が許されるようになりま......なくなりました。
p Float(nil)
=> ruby 1.6.7 (2002-03-01) [i586-linux]
0.0
=> -:1:in `Float': cannot convert nil into Float (TypeError)
from -:1
ruby 1.7.3 (2002-09-02) [i586-linux]
=== ARGF
: ((<ARGF#to_s|ARGF/to_s>)) [change]...