Module: Xyml
- Defined in:
- lib/ixyml/xyml.rb
Overview
参考:Xyml_elementモジュール
Defined Under Namespace
Constant Summary collapse
- Indent =
Indent used in a YAML file. Two spaces.
YAMLファイルとしてのインデント。スペース2個。
' '
- SequenceEntry =
‘- ’ : String for sequence(Array) entry in a YAML file.
‘- ’ : YAMLファイルのシーケンス(配列)要素を表す文字列
'- '
- MappingValue =
‘: ’ : String for mapping(hash) value in a YAML file.
‘: ’ : YAMLファイルのマッピング(ハッシュ)の値を表す文字列
': '
- LiteralBlock =
‘| ’ : String for literal block in a YAML file.
‘| ’ : YAMLファイルのリテラルブロックを表す文字列
'| '
Class Method Summary collapse
-
.doc2file(doc, io) ⇒ Object
print out a XYML element tree to a XYML file.
-
.domobj2element(domobj) ⇒ Object
convert a DOM object tree into a XYML element tree.
-
.extend_element(rawobj) ⇒ Object
extend each hash in a tree composed of alternate hashes and arrays to a XYML element, and obtain a XYML element tree.
-
.rawobj2domobj(rawobj) ⇒ Object
convert a tree composed of alternate hashes and arrays into a DOM object tree.
-
.rawobj2element(rawobj) ⇒ Object
convert a tree composed of alternate hashes and arrays into a XYML element tree.
-
.rawobj2xmlString(rawobj) ⇒ Object
convert a tree composed of alternate hashes and arrays into XML strings.
Class Method Details
.doc2file(doc, io) ⇒ Object
print out a XYML element tree to a XYML file.
XYMLエレメントのツリーをXYMLファイルとしてプリントアウトする。
Args
- doc
-
an instance of Xyml::Document.
- io
-
output IO.
250 251 252 253 254 |
# File 'lib/ixyml/xyml.rb', line 250 def self.doc2file doc,io io.print "---\n" Xyml.doc2file_rcsv(doc,0,io) end |
.domobj2element(domobj) ⇒ Object
convert a DOM object tree into a XYML element tree.
DOMオブジェクトのツリーをXYMLエレメントのツリーに変換する。
Args
- domobj
-
an instance of REXML::Document.
Return
the root element of a created XYML element tree.
生成されたXYMLエレメントツリーのルートエレメント
238 239 240 241 242 |
# File 'lib/ixyml/xyml.rb', line 238 def self.domobj2element domobj temproot=Hash.new temproot.extend Xyml_element Xyml.domobj2element_rcsv domobj,temproot,nil end |
.extend_element(rawobj) ⇒ Object
extend each hash in a tree composed of alternate hashes and arrays to a XYML element, and obtain a XYML element tree. This method is similar to rawobj2element method except that extend_element does not create new hashes and arrays. In order to apply this method to a tree, all hashes in that tree must use symbols as hash keys.
ハッシュと配列とを交互に組み合わせたツリー中のハッシュをXYMLエレメントに拡張し、 XYMLエレメントツリーを得る。このメソッドは、 rawobj2elementと似ているが、新たにハッシュと配列を 生成しない点が異なっている。このメソッドを適用するツリーでは、ハッシュのキーはすべてシンボルで なければならない。
Args
- rawobj
-
the root of a tree composed of alternate hashes and arrays
Return
the root element of a created XYML element tree, which is identical to rawobj in the input argument.
225 226 227 |
# File 'lib/ixyml/xyml.rb', line 225 def self.extend_element rawobj Xyml.extend_element_rcsv rawobj,nil end |
.rawobj2domobj(rawobj) ⇒ Object
convert a tree composed of alternate hashes and arrays into a DOM object tree. note that a XYML element tree is such a tree that can be converted by this method.
ハッシュと配列とを交互に組み合わせたツリーを、DOMオブジェクトのツリーに変換する。 XYMLエレメントのツリーも、このメソッドにより変換されるツリーとなっていることに注意。
Args
- rawobj
-
the root of a tree composed of alternate hashes and arrays.
Return
an instance of REXML::Document.
205 206 207 208 209 210 |
# File 'lib/ixyml/xyml.rb', line 205 def self.rawobj2domobj rawobj dom = REXML::Document.new <<EOS <?xml version='1.0' encoding='UTF-8'?> EOS Xyml.rawobj2domobj_rcsv rawobj,dom end |
.rawobj2element(rawobj) ⇒ Object
convert a tree composed of alternate hashes and arrays into a XYML element tree.
ハッシュと配列とを交互に組み合わせたツリーを、XYMLエレメントのツリーに変換する。
Args
- rawobj
-
the root of a tree composed of alternate hashes and arrays
Return
the root element of a created XYML element tree.
172 173 174 175 176 177 |
# File 'lib/ixyml/xyml.rb', line 172 def self.rawobj2element rawobj temp_root=Xyml::Element.new :tempRoot Xyml.rawobj2element_rcsv rawobj,temp_root temp_root[:tempRoot][0]._sp(:_iamroot) temp_root[:tempRoot][0] end |
.rawobj2xmlString(rawobj) ⇒ Object
convert a tree composed of alternate hashes and arrays into XML strings. note that a XYML element tree is such a tree to be converted by this method.
ハッシュと配列とを交互に組み合わせたツリーを、XMLの文字列に変換する。 XYMLエレメントのツリーも、このメソッドにより変換されるツリーとなっていることに注意。
Args
- rawobj
-
the root of a tree composed of alternate hashes and arrays.
Return
strings in XML.
188 189 190 191 192 193 |
# File 'lib/ixyml/xyml.rb', line 188 def self.rawobj2xmlString rawobj sio=StringIO.new Xyml.rawobj2domobj(rawobj).write(sio) sio.rewind sio.read end |