オープンソース・ソフトウェアの開発とダウンロード

CVS リポジトリの参照

Contents of /perldocjp/docs/modules/YAML-0.35/YAML/Node.pod

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download)
Thu Jan 27 13:15:10 2011 UTC (13 years, 3 months ago) by iwai
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +3 -0 lines
add encoding tag

1
2 =encoding euc-jp
3
4 =head1 NAME
5
6 =begin original
7
8 YAML::Node - A generic data node that encapsulates YAML information
9
10 =end original
11
12 YAML::Node - YAML 情報をカプセル化する汎用データノード
13
14 =head1 SYNOPSIS
15
16 use YAML;
17 use YAML::Node;
18
19 my $ynode = YAML::Node->new({}, 'ingerson.com/fruit');
20 %$ynode = qw(orange orange apple red grape green);
21 print Dump $ynode;
22
23 =begin original
24
25 yields:
26
27 =end original
28
29 とすると:
30
31 --- #YAML:1.0 !ingerson.com/fruit
32 orange: orange
33 apple: red
34 grape: green
35
36 =head1 DESCRIPTION
37
38 =begin original
39
40 A generic node in YAML is similar to a plain hash, array, or scalar node
41 in Perl except that it must also keep track of its type. The type is a
42 URI called the YAML type family.
43
44 =end original
45
46 YAML の汎用ノードは Perl での普通のハッシュ、配列、スカラノードと
47 似ていますが、型を保存しているところが違います。
48 この型は YAML 型ファミリと呼ばれる URI です。
49
50 =begin original
51
52 YAML::Node is a class for generating and manipulating these containers.
53 A YAML node (or ynode) is a tied hash, array or scalar. In most ways it
54 behaves just like the plain thing. But you can assign and retrieve and
55 YAML type family URI to it. For the hash flavor, you can also assign the
56 order that the keys will be retrieved in. By default a ynode will offer
57 its keys in the same order that they were assigned.
58
59 =end original
60
61 YAML::Node はこれらのコンテナを生成、操作するためのクラスです。
62 YAML ノード(ynode)はハッシュ、配列、スカラのいずれかと結び付けられます。
63 ほとんどの場合これは普通のものと同じように振る舞います。
64 しかし、YAML 型ファミリ URI を割り当てたり所得したりできます。
65 ハッシュ用には、キーを取り出す順番を割り当てることもできます。
66 デフォルトでは ynode は割り当てられたのと同じ順番で提供されます。
67
68 =begin original
69
70 YAML::Node has a class method call new() that will return a ynode. You
71 pass it a regular node and an optional type family. After that you can
72 use it like a normal Perl node, but when you YAML::Dump it, the magical
73 properties will be honored.
74
75 =end original
76
77 YAML::Node は ynode を返す new() クラスメソッド呼び出しを持ちます。
78 引数として通常のノードと、オプションの型ファミリを渡します。
79 その後、これを通常の Perl ノードとどう夜につかうことができますが、
80 YAML::Dump を使ったときに、秘密のプロパティが効力をもちます。
81
82 =begin original
83
84 This is how you can control the sort order of hash keys during a YAML
85 serialization. By default, YAML sorts keys alphabetically. But notice
86 in the above example that the keys were Dumped in the same order they
87 were assigned.
88
89 =end original
90
91 これが YAML 直列化でハッシュキーのソート順を制御する方法です。
92 デフォルトでは、YAML はキーをアルファベット順にソートします。
93 しかし、上記の例では、割り当てられたのと同じ順番で Dump されています。
94
95 =begin original
96
97 YAML::Node exports a function called ynode(). This function returns the tied object so that you can call special methods on it like ->keys().
98
99 =end original
100
101 YAML::Node は ynode() 関数をエクスポートします。
102 この関数は結び付けられたオブジェクトを返すので、
103 返り値に対して ->keys() のような特別なメソッドを呼び出せます。
104
105 =begin original
106
107 keys() works like this:
108
109 =end original
110
111 keys() は以下のように動作します:
112
113 use YAML;
114 use YAML::Node;
115
116 %$node = qw(orange orange apple red grape green);
117 $ynode = YAML::Node->new($node);
118 ynode($ynode)->keys(['grape', 'apple']);
119 print Dump $ynode;
120
121 =begin original
122
123 produces:
124
125 =end original
126
127 出力は以下のようになります:
128
129 --- #YAML:1.0
130 grape: green
131 apple: red
132
133 =begin original
134
135 It tells the ynode which keys and what order to use.
136
137 =end original
138
139 これにより、ynode が どのキーをどのような順番で使うのかがわかります。
140
141 =begin original
142
143 ynodes will play a very important role in how programs use YAML. They
144 are the foundation of how a Perl class can marshall the Loading and
145 Dumping of its objects.
146
147 =end original
148
149 ynode は プログラムがどのように YAML を使うかにおいて重要な
150 役割を演じます。これはオブジェクトを Load したり Dump したりするときに
151 Perl クラスがどのように整列させるかの基礎となります。
152
153 =begin original
154
155 The upcoming versions of YAML.pm will have much more information on this.
156
157 =end original
158
159 YAML.pm の将来のバージョンではより多くの情報を持つ予定です。
160
161 =head1 AUTHOR
162
163 Brian Ingerson <INGY@cpan.org>
164
165 =head1 COPYRIGHT
166
167 Copyright (c) 2002. Brian Ingerson. All rights reserved.
168
169 This program is free software; you can redistribute it and/or modify it
170 under the same terms as Perl itself.
171
172 See L<http://www.perl.com/perl/misc/Artistic.html>
173

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26