Class: Meteor::Element
- Inherits:
-
Object
- Object
- Meteor::Element
- Defined in:
- lib/meteor.rb
Overview
Element Class (要素クラス)
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attributes ⇒ String
Attributes (属性群).
-
#copy ⇒ Meteor::Element
Copy pointer (複製ポインタ).
-
#cx ⇒ true, false
Comment extension tag flag (コメント拡張タグフラグ).
-
#document_sync ⇒ true, false
Document update flag (ドキュメント更新フラグ).
-
#empty ⇒ true, false
Content empty flag (内容存在フラグ).
-
#mixed_content ⇒ String
Content (内容).
-
#mono ⇒ true, false
Child element existance flag (子要素存在フラグ).
-
#origin ⇒ Meteor::Element
Original pointer (原本ポインタ).
-
#parser ⇒ Meteor::Parser
Parser(パーサ).
-
#pattern ⇒ String
Pattern (パターン).
-
#raw_content ⇒ false, true
Entity ref flag of content (内容のエンティティ参照フラグ).
-
#removed ⇒ true, false
Delete flag (削除フラグ).
-
#tag ⇒ Object
(also: #name)
Returns the value of attribute tag.
-
#type_value ⇒ String
Type (タイプ属性).
-
#usable ⇒ true, false
Usable flag (有効・無効フラグ).
Class Method Summary collapse
-
.new!(elm, ps) ⇒ Meteor::Element
make copy (コピーを作成する).
Instance Method Summary collapse
-
#[](name) ⇒ String
get attribute value (属性の値を取得する).
-
#[]=(name, value) ⇒ Meteor::Element
set attribute (属性をセットする).
- #attr(attrs, *args) ⇒ Object
-
#attr=(attr) ⇒ Meteor::Element
set attribute of element (要素の属性をセットする).
- #attr_map(*args) ⇒ Object
-
#attr_map=(attr_map) ⇒ Meteor::Element
set attribute map (属性マップをセットする).
-
#attrs ⇒ Hash<String,String>, Hash<Symbol,String>
get attribute map (属性マップを取得する).
-
#attrs=(attrs) ⇒ Meteor::Element
set attribute map (要素マップをセットする).
-
#clone ⇒ Meteor::Element
clone (複製する).
- #content(*args) ⇒ Object
-
#content=(value) ⇒ Meteor::Element
set content of element (要素の内容をセットする).
-
#cxtag(*args) ⇒ Object
get cx(comment extension) tag (CX(コメント拡張)タグを取得する).
-
#document ⇒ String
get document (ドキュメントを取得する).
-
#document=(doc) ⇒ Object
set document (ドキュメントをセットする).
-
#element(elm = nil, attrs = nil, *args) ⇒ Object
(also: #child)
get element (要素を取得する).
-
#elements(*args) ⇒ Object
get elements (要素を取得する).
- #execute(*args) ⇒ Object
-
#find(selector) ⇒ Array<Meteor::Element>
(also: #css)
get (child) elements using selector like css3(CSS3のようにセレクタを用いて(子)要素を取得する) CSS3 selector partial support (CSS3セレクタの部分的サポート).
-
#flush ⇒ Object
reflect (反映する).
-
#initialize(*args) ⇒ Element
constructor
initializer (イニシャライザ).
-
#remove ⇒ Object
remove element (要素を削除する).
-
#remove_attr(attr_name) ⇒ Meteor::Element
remove attribute of element (要素の属性を消す).
Constructor Details
#initialize(tag) ⇒ Element #initialize(elm) ⇒ Element #initialize(elm, ps) ⇒ Element
initializer (イニシャライザ)
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/meteor.rb', line 110 def initialize(*args) case args.length when ONE if args[0].kind_of?(String) initialize_s(args[0]) elsif args[0].kind_of?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when TWO @tag = args[0].tag @attributes = String.new(args[0].attributes) @mixed_content = String.new(args[0].mixed_content) #@pattern = String.new(args[0].pattern) @pattern = args[0].pattern @document = String.new(args[0].document) @empty = args[0].empty @cx = args[0].cx @mono = args[0].mono @parser = args[1] #@usable = false @origin = args[0] args[0].copy = self when ZERO else raise ArgumentError end end |
Instance Attribute Details
#attributes ⇒ String
Returns attributes (属性群).
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
# File 'lib/meteor.rb', line 79 class Element attr_accessor :tag attr_accessor :attributes attr_accessor :mixed_content attr_accessor :raw_content attr_accessor :pattern attr_accessor :document_sync attr_accessor :empty attr_accessor :cx attr_accessor :mono attr_accessor :parser attr_accessor :type_value attr_accessor :usable attr_accessor :origin attr_accessor :copy attr_accessor :removed alias :name :tag alias :name= :tag= # # initializer (イニシャライザ) # @overload initialize(tag) # @param [String,Symbol] tag tag name (タグ名) # @overload initialize(elm) # @param [Meteor::Element] elm element (要素) # @overload initialize(elm,ps) # @param [Meteor::Element] elm element (要素) # @param [Meteor::Parser] ps parser (パーサ) # def initialize(*args) case args.length when ONE if args[0].kind_of?(String) initialize_s(args[0]) elsif args[0].kind_of?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when TWO @tag = args[0].tag @attributes = String.new(args[0].attributes) @mixed_content = String.new(args[0].mixed_content) #@pattern = String.new(args[0].pattern) @pattern = args[0].pattern @document = String.new(args[0].document) @empty = args[0].empty @cx = args[0].cx @mono = args[0].mono @parser = args[1] #@usable = false @origin = args[0] args[0].copy = self when ZERO else raise ArgumentError end end # # initializer (イニシャライザ) # @param [String] tag tag name (タグ名) # def initialize_s(tag) @tag = tag #@attributes = nil #@mixed_content = nil #@pattern = nil #@document = nil #@parser=nil #@empty = false #@cx = false #@mono = false #@parent = false @usable = true end private :initialize_s # # initializer (イニシャライザ) # @param [Meteor::Element] elm element (要素) # def initialize_e(elm) @tag = elm.tag @attributes = String.new(elm.attributes) #@pattern = String.new(elm.pattern) @pattern = elm.pattern @document = String.new(elm.document) @empty = elm.empty @cx = elm.cx @mono = elm.mono @origin = elm @parser = elm.parser @usable = true end private :initialize_e # # make copy (コピーを作成する) # @overload new!(elm,ps) # @param [Meteor::Element] elm element (要素) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def self.new!(*args) case args.length when TWO @obj = args[1].element_hook if @obj @obj.attributes = String.new(args[0].attributes) @obj.mixed_content = String.new(args[0].mixed_content) #@obj.pattern = String.new(args[0].pattern) @obj.document = String.new(args[0].document) @obj else @obj = self.new(args[0], args[1]) args[1].element_hook = @obj @obj end else raise ArgumentError end end # # clone (複製する) # @return [Meteor::Element] element (要素) # def clone obj = self.parser.element_cache[self.object_id] if obj obj.attributes = String.new(self.attributes) obj.mixed_content = String.new(self.mixed_content) #obj.pattern = String.new(self.pattern) obj.document = String.new(self.document) obj.usable = true obj else obj = self.new(self) self.parser.element_cache[self.object_id] = obj obj end end # # set document (ドキュメントをセットする) # @param [String] doc document (ドキュメント) # def document=(doc) @document_sync = false @document = doc end # # get document (ドキュメントを取得する) # @return [String] document (ドキュメント) # def document if @document_sync @document_sync = false case @parser.doc_type when Parser::HTML, Parser::HTML5 if @cx #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4 @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->" else if @empty #@pattern_cc = '' << TAG_OPEN << elm.tag << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.tag << TAG_CLOSE @document = "<#{@tag}#{@attributes}>#{@mixed_content}</#{@tag}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @tag << @attributes << Meteor::Core::Kernel::TAG_CLOSE #@document = "<#{@name}#{@attributes}>" end end when Parser::XHTML, Parser::XHTML5, Parser::XML if @cx #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4 @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->" else if @empty #@pattern_cc = '' << TAG_OPEN << elm.tag << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.tag << TAG_CLOSE @document = "<#{@tag}#{@attributes}>#{@mixed_content}</#{@tag}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @tag << @attributes << Meteor::Core::Kernel::TAG_CLOSE3 #@document = "<#{@name}#{@attributes}/>" end end end else @document end end # # get element (要素を取得する) # @overload element() # get element (要素を取得する) # @return [Meteor::Element] element (要素) # @overload element(tag) # get element using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @return [Meteor::Element] element (要素) # @overload element(tag,attrs) # get element using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element (要素) # @overload element(attrs) # get element using attribute map (属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element(要素) # @overload element(tag,attr_name,attr_value) # get element using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Meteor::Element] element (要素) # @overload element(attr_name,attr_value) # get element using attribute(name="value") (属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name 属性名 # @param [String] attr_value 属性値 # @return [Meteor::Element] element (要素) # @overload element(tag,attr_name1,attr_value1,attr_name2,attr_value2) # get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Meteor::Element] element (要素) # @overload element(attr_name1,attr_value1,attr_name2,attr_value2) # get element using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name1 属性名1 # @param [String] attr_value1 属性値1 # @param [String,Symbol] attr_name2 属性名2 # @param [String] attr_value2 属性値2 # @return [Meteor::Element] element(要素) # @overload element(elm) # mirror element (要素を射影する) # @param [Meteor::Element] elm element(要素) # @return [Meteor::Element] element(要素) # def element(elm = nil, attrs = nil,*args) #case args.length #when ZERO if !elm && !attrs @parser.element(self) else @parser.element(elm, attrs,*args) end end alias :child :element # # get elements (要素を取得する) # @overload elements(tag) # get elements using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @return [Array<Meteor::Element>] element array(要素配列) # @overload elements(tag,attrs) # get elements using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attrs) # get elements using attribute map (属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(tag,attr_name,attr_value) # get elements using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attr_name,attr_value) # get elements using attribute(name="value") (属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(tag,attr_name1,attr_value1,attr_name2,attr_value2) # get elements using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attr_name1,attr_value1,attr_name2,attr_value2) # get elements using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Array<Meteor::Element>] element array (要素配列) # def elements(*args) @parser.elements(*args) end # # get (child) elements using selector like css3(CSS3のようにセレクタを用いて(子)要素を取得する) # CSS3 selector partial support (CSS3セレクタの部分的サポート) # @param selector [String] selector (セレクタ) # @return [Array<Meteor::Element>] element (要素) # def find(selector) @parser.find(selector) end alias :css :find # # get cx(comment extension) tag (CX(コメント拡張)タグを取得する) # @overload cxtag(tag,id) # get cx(comment extension) tag using tag name and id attribute (タグ名とID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String] id id attribute value (ID属性値) # @return [Meteor::Element] element(要素) # @overload cxtag(id) # get cx(comment extension) tag using id attribute (ID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String] id id attribute value (ID属性値) # @return [Meteor::Element] element (要素) # def cxtag(*args) @parser.cxtag(*args) end # # @overload attr(attr) # set attribute of element (要素の属性をセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attr attribute (属性) # @return [Meteor::Element] element (要素) # @deprecated # @overload attr(attr_name,attr_value) # set attribute of element (要素の属性をセットする) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String,true,false] attr_value attribute value (属性値) # @return [Meteor::Element] element (要素) # @overload attr(attr_name) # get attribute value of element (要素の属性値を取得する) # @param [String,Symbol] attr_name attribute name (属性名) # @return [String] attribute value (属性値) # def attr(attrs,*args) @parser.attr(self, attrs,*args) end # # set attribute of element (要素の属性をセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attr attribute (属性) # @return [Meteor::Element] element (要素) # def attr=(attr) @parser.attr(self,attr) end # # set attribute map (要素マップをセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element (要素) def attrs=(attrs) @parser.attrs(self,attrs) end # # get attribute map (属性マップを取得する) # @return [Hash<String,String>,Hash<Symbol,String>] attribute map (属性マップ) # def attrs @parser.attrs(self) end # # @overload attr_map(attr_map) # set attribute map (属性マップをセットする) # @param [Meteor::AttributeMap] attr_map attribute map (属性マップ) # @return [Meteor::Element] element (要素) # @deprecated # @overload attr_map() # get attribute map (属性マップを取得する) # @return [Meteor::AttributeMap] attribute map (属性マップ) # def attr_map(*args) @parser.attr_map(self, *args) end # # set attribute map (属性マップをセットする) # @param [Meteor::AttributeMap] attr_map attribute map (属性マップ) # @return [Meteor::Element] element (要素) # def attr_map=(attr_map) @parser.attr_map(self,attr_map) end # # @overload content(content,entity_ref=true) # set content of element (要素の内容をセットする) # @param [String] content content of element (要素の内容) # @param [true,false] entity_ref entity reference flag (エンティティ参照フラグ) # @return [Meteor::Element] element (要素) # @deprecated # @overload content(content) # set content of element (要素の内容をセットする) # @param [String] content content of element (要素の内容) # @return [Meteor::Element] element (要素) # @deprecated # @overload content() # get content of element (要素の内容を取得する) # @return [String] content (内容) # def content(*args) @parser.content(self, *args) end # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def content=(value) @parser.content(self, value) end # # set attribute (属性をセットする) # @param [String,Symbol] name attribute name (属性の名前) # @param [String] value attribute value (属性の値) # @return [Meteor::Element] element (要素) # def []=(name, value) @parser.attr(self, name, value) end # # get attribute value (属性の値を取得する) # @param [String,Symbol] name attribute name (属性の名前) # @return [String] attribute value (属性の値) # def [](name) @parser.attr(self, name) end # # remove attribute of element (要素の属性を消す) # @param [String,Symbol] attr_name attribute name (属性名) # @return [Meteor::Element] element (要素) # def remove_attr(attr_name) @parser.remove_attr(self, attr_name) end # # remove element (要素を削除する) # def remove @parser.remove_element(self) end # # reflect (反映する) # def flush @parser.flush end # # @overload execute(hook) # run action of Hooker (Hookerクラスの処理を実行する) # @param [Meteor::Hook::Hooker] hook Hooker object (Hookerオブジェクト) # @overload execute(loop,list) # run action of Looper (Looperクラスの処理を実行する) # @param [Meteor::Hook::Looper] loop Looper object (Looperオブジェクト) # @param [Array] list 配列 # def execute(*args) @parser.execute(self, *args) end end |
#copy ⇒ Meteor::Element
Returns copy pointer (複製ポインタ).
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
# File 'lib/meteor.rb', line 79 class Element attr_accessor :tag attr_accessor :attributes attr_accessor :mixed_content attr_accessor :raw_content attr_accessor :pattern attr_accessor :document_sync attr_accessor :empty attr_accessor :cx attr_accessor :mono attr_accessor :parser attr_accessor :type_value attr_accessor :usable attr_accessor :origin attr_accessor :copy attr_accessor :removed alias :name :tag alias :name= :tag= # # initializer (イニシャライザ) # @overload initialize(tag) # @param [String,Symbol] tag tag name (タグ名) # @overload initialize(elm) # @param [Meteor::Element] elm element (要素) # @overload initialize(elm,ps) # @param [Meteor::Element] elm element (要素) # @param [Meteor::Parser] ps parser (パーサ) # def initialize(*args) case args.length when ONE if args[0].kind_of?(String) initialize_s(args[0]) elsif args[0].kind_of?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when TWO @tag = args[0].tag @attributes = String.new(args[0].attributes) @mixed_content = String.new(args[0].mixed_content) #@pattern = String.new(args[0].pattern) @pattern = args[0].pattern @document = String.new(args[0].document) @empty = args[0].empty @cx = args[0].cx @mono = args[0].mono @parser = args[1] #@usable = false @origin = args[0] args[0].copy = self when ZERO else raise ArgumentError end end # # initializer (イニシャライザ) # @param [String] tag tag name (タグ名) # def initialize_s(tag) @tag = tag #@attributes = nil #@mixed_content = nil #@pattern = nil #@document = nil #@parser=nil #@empty = false #@cx = false #@mono = false #@parent = false @usable = true end private :initialize_s # # initializer (イニシャライザ) # @param [Meteor::Element] elm element (要素) # def initialize_e(elm) @tag = elm.tag @attributes = String.new(elm.attributes) #@pattern = String.new(elm.pattern) @pattern = elm.pattern @document = String.new(elm.document) @empty = elm.empty @cx = elm.cx @mono = elm.mono @origin = elm @parser = elm.parser @usable = true end private :initialize_e # # make copy (コピーを作成する) # @overload new!(elm,ps) # @param [Meteor::Element] elm element (要素) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def self.new!(*args) case args.length when TWO @obj = args[1].element_hook if @obj @obj.attributes = String.new(args[0].attributes) @obj.mixed_content = String.new(args[0].mixed_content) #@obj.pattern = String.new(args[0].pattern) @obj.document = String.new(args[0].document) @obj else @obj = self.new(args[0], args[1]) args[1].element_hook = @obj @obj end else raise ArgumentError end end # # clone (複製する) # @return [Meteor::Element] element (要素) # def clone obj = self.parser.element_cache[self.object_id] if obj obj.attributes = String.new(self.attributes) obj.mixed_content = String.new(self.mixed_content) #obj.pattern = String.new(self.pattern) obj.document = String.new(self.document) obj.usable = true obj else obj = self.new(self) self.parser.element_cache[self.object_id] = obj obj end end # # set document (ドキュメントをセットする) # @param [String] doc document (ドキュメント) # def document=(doc) @document_sync = false @document = doc end # # get document (ドキュメントを取得する) # @return [String] document (ドキュメント) # def document if @document_sync @document_sync = false case @parser.doc_type when Parser::HTML, Parser::HTML5 if @cx #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4 @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->" else if @empty #@pattern_cc = '' << TAG_OPEN << elm.tag << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.tag << TAG_CLOSE @document = "<#{@tag}#{@attributes}>#{@mixed_content}</#{@tag}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @tag << @attributes << Meteor::Core::Kernel::TAG_CLOSE #@document = "<#{@name}#{@attributes}>" end end when Parser::XHTML, Parser::XHTML5, Parser::XML if @cx #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4 @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->" else if @empty #@pattern_cc = '' << TAG_OPEN << elm.tag << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.tag << TAG_CLOSE @document = "<#{@tag}#{@attributes}>#{@mixed_content}</#{@tag}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @tag << @attributes << Meteor::Core::Kernel::TAG_CLOSE3 #@document = "<#{@name}#{@attributes}/>" end end end else @document end end # # get element (要素を取得する) # @overload element() # get element (要素を取得する) # @return [Meteor::Element] element (要素) # @overload element(tag) # get element using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @return [Meteor::Element] element (要素) # @overload element(tag,attrs) # get element using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element (要素) # @overload element(attrs) # get element using attribute map (属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element(要素) # @overload element(tag,attr_name,attr_value) # get element using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Meteor::Element] element (要素) # @overload element(attr_name,attr_value) # get element using attribute(name="value") (属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name 属性名 # @param [String] attr_value 属性値 # @return [Meteor::Element] element (要素) # @overload element(tag,attr_name1,attr_value1,attr_name2,attr_value2) # get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Meteor::Element] element (要素) # @overload element(attr_name1,attr_value1,attr_name2,attr_value2) # get element using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name1 属性名1 # @param [String] attr_value1 属性値1 # @param [String,Symbol] attr_name2 属性名2 # @param [String] attr_value2 属性値2 # @return [Meteor::Element] element(要素) # @overload element(elm) # mirror element (要素を射影する) # @param [Meteor::Element] elm element(要素) # @return [Meteor::Element] element(要素) # def element(elm = nil, attrs = nil,*args) #case args.length #when ZERO if !elm && !attrs @parser.element(self) else @parser.element(elm, attrs,*args) end end alias :child :element # # get elements (要素を取得する) # @overload elements(tag) # get elements using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @return [Array<Meteor::Element>] element array(要素配列) # @overload elements(tag,attrs) # get elements using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attrs) # get elements using attribute map (属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(tag,attr_name,attr_value) # get elements using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attr_name,attr_value) # get elements using attribute(name="value") (属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(tag,attr_name1,attr_value1,attr_name2,attr_value2) # get elements using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attr_name1,attr_value1,attr_name2,attr_value2) # get elements using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Array<Meteor::Element>] element array (要素配列) # def elements(*args) @parser.elements(*args) end # # get (child) elements using selector like css3(CSS3のようにセレクタを用いて(子)要素を取得する) # CSS3 selector partial support (CSS3セレクタの部分的サポート) # @param selector [String] selector (セレクタ) # @return [Array<Meteor::Element>] element (要素) # def find(selector) @parser.find(selector) end alias :css :find # # get cx(comment extension) tag (CX(コメント拡張)タグを取得する) # @overload cxtag(tag,id) # get cx(comment extension) tag using tag name and id attribute (タグ名とID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String] id id attribute value (ID属性値) # @return [Meteor::Element] element(要素) # @overload cxtag(id) # get cx(comment extension) tag using id attribute (ID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String] id id attribute value (ID属性値) # @return [Meteor::Element] element (要素) # def cxtag(*args) @parser.cxtag(*args) end # # @overload attr(attr) # set attribute of element (要素の属性をセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attr attribute (属性) # @return [Meteor::Element] element (要素) # @deprecated # @overload attr(attr_name,attr_value) # set attribute of element (要素の属性をセットする) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String,true,false] attr_value attribute value (属性値) # @return [Meteor::Element] element (要素) # @overload attr(attr_name) # get attribute value of element (要素の属性値を取得する) # @param [String,Symbol] attr_name attribute name (属性名) # @return [String] attribute value (属性値) # def attr(attrs,*args) @parser.attr(self, attrs,*args) end # # set attribute of element (要素の属性をセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attr attribute (属性) # @return [Meteor::Element] element (要素) # def attr=(attr) @parser.attr(self,attr) end # # set attribute map (要素マップをセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element (要素) def attrs=(attrs) @parser.attrs(self,attrs) end # # get attribute map (属性マップを取得する) # @return [Hash<String,String>,Hash<Symbol,String>] attribute map (属性マップ) # def attrs @parser.attrs(self) end # # @overload attr_map(attr_map) # set attribute map (属性マップをセットする) # @param [Meteor::AttributeMap] attr_map attribute map (属性マップ) # @return [Meteor::Element] element (要素) # @deprecated # @overload attr_map() # get attribute map (属性マップを取得する) # @return [Meteor::AttributeMap] attribute map (属性マップ) # def attr_map(*args) @parser.attr_map(self, *args) end # # set attribute map (属性マップをセットする) # @param [Meteor::AttributeMap] attr_map attribute map (属性マップ) # @return [Meteor::Element] element (要素) # def attr_map=(attr_map) @parser.attr_map(self,attr_map) end # # @overload content(content,entity_ref=true) # set content of element (要素の内容をセットする) # @param [String] content content of element (要素の内容) # @param [true,false] entity_ref entity reference flag (エンティティ参照フラグ) # @return [Meteor::Element] element (要素) # @deprecated # @overload content(content) # set content of element (要素の内容をセットする) # @param [String] content content of element (要素の内容) # @return [Meteor::Element] element (要素) # @deprecated # @overload content() # get content of element (要素の内容を取得する) # @return [String] content (内容) # def content(*args) @parser.content(self, *args) end # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def content=(value) @parser.content(self, value) end # # set attribute (属性をセットする) # @param [String,Symbol] name attribute name (属性の名前) # @param [String] value attribute value (属性の値) # @return [Meteor::Element] element (要素) # def []=(name, value) @parser.attr(self, name, value) end # # get attribute value (属性の値を取得する) # @param [String,Symbol] name attribute name (属性の名前) # @return [String] attribute value (属性の値) # def [](name) @parser.attr(self, name) end # # remove attribute of element (要素の属性を消す) # @param [String,Symbol] attr_name attribute name (属性名) # @return [Meteor::Element] element (要素) # def remove_attr(attr_name) @parser.remove_attr(self, attr_name) end # # remove element (要素を削除する) # def remove @parser.remove_element(self) end # # reflect (反映する) # def flush @parser.flush end # # @overload execute(hook) # run action of Hooker (Hookerクラスの処理を実行する) # @param [Meteor::Hook::Hooker] hook Hooker object (Hookerオブジェクト) # @overload execute(loop,list) # run action of Looper (Looperクラスの処理を実行する) # @param [Meteor::Hook::Looper] loop Looper object (Looperオブジェクト) # @param [Array] list 配列 # def execute(*args) @parser.execute(self, *args) end end |
#cx ⇒ true, false
Returns comment extension tag flag (コメント拡張タグフラグ).
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
# File 'lib/meteor.rb', line 79 class Element attr_accessor :tag attr_accessor :attributes attr_accessor :mixed_content attr_accessor :raw_content attr_accessor :pattern attr_accessor :document_sync attr_accessor :empty attr_accessor :cx attr_accessor :mono attr_accessor :parser attr_accessor :type_value attr_accessor :usable attr_accessor :origin attr_accessor :copy attr_accessor :removed alias :name :tag alias :name= :tag= # # initializer (イニシャライザ) # @overload initialize(tag) # @param [String,Symbol] tag tag name (タグ名) # @overload initialize(elm) # @param [Meteor::Element] elm element (要素) # @overload initialize(elm,ps) # @param [Meteor::Element] elm element (要素) # @param [Meteor::Parser] ps parser (パーサ) # def initialize(*args) case args.length when ONE if args[0].kind_of?(String) initialize_s(args[0]) elsif args[0].kind_of?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when TWO @tag = args[0].tag @attributes = String.new(args[0].attributes) @mixed_content = String.new(args[0].mixed_content) #@pattern = String.new(args[0].pattern) @pattern = args[0].pattern @document = String.new(args[0].document) @empty = args[0].empty @cx = args[0].cx @mono = args[0].mono @parser = args[1] #@usable = false @origin = args[0] args[0].copy = self when ZERO else raise ArgumentError end end # # initializer (イニシャライザ) # @param [String] tag tag name (タグ名) # def initialize_s(tag) @tag = tag #@attributes = nil #@mixed_content = nil #@pattern = nil #@document = nil #@parser=nil #@empty = false #@cx = false #@mono = false #@parent = false @usable = true end private :initialize_s # # initializer (イニシャライザ) # @param [Meteor::Element] elm element (要素) # def initialize_e(elm) @tag = elm.tag @attributes = String.new(elm.attributes) #@pattern = String.new(elm.pattern) @pattern = elm.pattern @document = String.new(elm.document) @empty = elm.empty @cx = elm.cx @mono = elm.mono @origin = elm @parser = elm.parser @usable = true end private :initialize_e # # make copy (コピーを作成する) # @overload new!(elm,ps) # @param [Meteor::Element] elm element (要素) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def self.new!(*args) case args.length when TWO @obj = args[1].element_hook if @obj @obj.attributes = String.new(args[0].attributes) @obj.mixed_content = String.new(args[0].mixed_content) #@obj.pattern = String.new(args[0].pattern) @obj.document = String.new(args[0].document) @obj else @obj = self.new(args[0], args[1]) args[1].element_hook = @obj @obj end else raise ArgumentError end end # # clone (複製する) # @return [Meteor::Element] element (要素) # def clone obj = self.parser.element_cache[self.object_id] if obj obj.attributes = String.new(self.attributes) obj.mixed_content = String.new(self.mixed_content) #obj.pattern = String.new(self.pattern) obj.document = String.new(self.document) obj.usable = true obj else obj = self.new(self) self.parser.element_cache[self.object_id] = obj obj end end # # set document (ドキュメントをセットする) # @param [String] doc document (ドキュメント) # def document=(doc) @document_sync = false @document = doc end # # get document (ドキュメントを取得する) # @return [String] document (ドキュメント) # def document if @document_sync @document_sync = false case @parser.doc_type when Parser::HTML, Parser::HTML5 if @cx #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4 @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->" else if @empty #@pattern_cc = '' << TAG_OPEN << elm.tag << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.tag << TAG_CLOSE @document = "<#{@tag}#{@attributes}>#{@mixed_content}</#{@tag}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @tag << @attributes << Meteor::Core::Kernel::TAG_CLOSE #@document = "<#{@name}#{@attributes}>" end end when Parser::XHTML, Parser::XHTML5, Parser::XML if @cx #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4 @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->" else if @empty #@pattern_cc = '' << TAG_OPEN << elm.tag << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.tag << TAG_CLOSE @document = "<#{@tag}#{@attributes}>#{@mixed_content}</#{@tag}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @tag << @attributes << Meteor::Core::Kernel::TAG_CLOSE3 #@document = "<#{@name}#{@attributes}/>" end end end else @document end end # # get element (要素を取得する) # @overload element() # get element (要素を取得する) # @return [Meteor::Element] element (要素) # @overload element(tag) # get element using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @return [Meteor::Element] element (要素) # @overload element(tag,attrs) # get element using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element (要素) # @overload element(attrs) # get element using attribute map (属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element(要素) # @overload element(tag,attr_name,attr_value) # get element using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Meteor::Element] element (要素) # @overload element(attr_name,attr_value) # get element using attribute(name="value") (属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name 属性名 # @param [String] attr_value 属性値 # @return [Meteor::Element] element (要素) # @overload element(tag,attr_name1,attr_value1,attr_name2,attr_value2) # get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Meteor::Element] element (要素) # @overload element(attr_name1,attr_value1,attr_name2,attr_value2) # get element using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name1 属性名1 # @param [String] attr_value1 属性値1 # @param [String,Symbol] attr_name2 属性名2 # @param [String] attr_value2 属性値2 # @return [Meteor::Element] element(要素) # @overload element(elm) # mirror element (要素を射影する) # @param [Meteor::Element] elm element(要素) # @return [Meteor::Element] element(要素) # def element(elm = nil, attrs = nil,*args) #case args.length #when ZERO if !elm && !attrs @parser.element(self) else @parser.element(elm, attrs,*args) end end alias :child :element # # get elements (要素を取得する) # @overload elements(tag) # get elements using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @return [Array<Meteor::Element>] element array(要素配列) # @overload elements(tag,attrs) # get elements using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attrs) # get elements using attribute map (属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(tag,attr_name,attr_value) # get elements using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attr_name,attr_value) # get elements using attribute(name="value") (属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(tag,attr_name1,attr_value1,attr_name2,attr_value2) # get elements using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attr_name1,attr_value1,attr_name2,attr_value2) # get elements using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Array<Meteor::Element>] element array (要素配列) # def elements(*args) @parser.elements(*args) end # # get (child) elements using selector like css3(CSS3のようにセレクタを用いて(子)要素を取得する) # CSS3 selector partial support (CSS3セレクタの部分的サポート) # @param selector [String] selector (セレクタ) # @return [Array<Meteor::Element>] element (要素) # def find(selector) @parser.find(selector) end alias :css :find # # get cx(comment extension) tag (CX(コメント拡張)タグを取得する) # @overload cxtag(tag,id) # get cx(comment extension) tag using tag name and id attribute (タグ名とID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String] id id attribute value (ID属性値) # @return [Meteor::Element] element(要素) # @overload cxtag(id) # get cx(comment extension) tag using id attribute (ID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String] id id attribute value (ID属性値) # @return [Meteor::Element] element (要素) # def cxtag(*args) @parser.cxtag(*args) end # # @overload attr(attr) # set attribute of element (要素の属性をセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attr attribute (属性) # @return [Meteor::Element] element (要素) # @deprecated # @overload attr(attr_name,attr_value) # set attribute of element (要素の属性をセットする) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String,true,false] attr_value attribute value (属性値) # @return [Meteor::Element] element (要素) # @overload attr(attr_name) # get attribute value of element (要素の属性値を取得する) # @param [String,Symbol] attr_name attribute name (属性名) # @return [String] attribute value (属性値) # def attr(attrs,*args) @parser.attr(self, attrs,*args) end # # set attribute of element (要素の属性をセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attr attribute (属性) # @return [Meteor::Element] element (要素) # def attr=(attr) @parser.attr(self,attr) end # # set attribute map (要素マップをセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element (要素) def attrs=(attrs) @parser.attrs(self,attrs) end # # get attribute map (属性マップを取得する) # @return [Hash<String,String>,Hash<Symbol,String>] attribute map (属性マップ) # def attrs @parser.attrs(self) end # # @overload attr_map(attr_map) # set attribute map (属性マップをセットする) # @param [Meteor::AttributeMap] attr_map attribute map (属性マップ) # @return [Meteor::Element] element (要素) # @deprecated # @overload attr_map() # get attribute map (属性マップを取得する) # @return [Meteor::AttributeMap] attribute map (属性マップ) # def attr_map(*args) @parser.attr_map(self, *args) end # # set attribute map (属性マップをセットする) # @param [Meteor::AttributeMap] attr_map attribute map (属性マップ) # @return [Meteor::Element] element (要素) # def attr_map=(attr_map) @parser.attr_map(self,attr_map) end # # @overload content(content,entity_ref=true) # set content of element (要素の内容をセットする) # @param [String] content content of element (要素の内容) # @param [true,false] entity_ref entity reference flag (エンティティ参照フラグ) # @return [Meteor::Element] element (要素) # @deprecated # @overload content(content) # set content of element (要素の内容をセットする) # @param [String] content content of element (要素の内容) # @return [Meteor::Element] element (要素) # @deprecated # @overload content() # get content of element (要素の内容を取得する) # @return [String] content (内容) # def content(*args) @parser.content(self, *args) end # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def content=(value) @parser.content(self, value) end # # set attribute (属性をセットする) # @param [String,Symbol] name attribute name (属性の名前) # @param [String] value attribute value (属性の値) # @return [Meteor::Element] element (要素) # def []=(name, value) @parser.attr(self, name, value) end # # get attribute value (属性の値を取得する) # @param [String,Symbol] name attribute name (属性の名前) # @return [String] attribute value (属性の値) # def [](name) @parser.attr(self, name) end # # remove attribute of element (要素の属性を消す) # @param [String,Symbol] attr_name attribute name (属性名) # @return [Meteor::Element] element (要素) # def remove_attr(attr_name) @parser.remove_attr(self, attr_name) end # # remove element (要素を削除する) # def remove @parser.remove_element(self) end # # reflect (反映する) # def flush @parser.flush end # # @overload execute(hook) # run action of Hooker (Hookerクラスの処理を実行する) # @param [Meteor::Hook::Hooker] hook Hooker object (Hookerオブジェクト) # @overload execute(loop,list) # run action of Looper (Looperクラスの処理を実行する) # @param [Meteor::Hook::Looper] loop Looper object (Looperオブジェクト) # @param [Array] list 配列 # def execute(*args) @parser.execute(self, *args) end end |
#document_sync ⇒ true, false
Returns document update flag (ドキュメント更新フラグ).
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
# File 'lib/meteor.rb', line 79 class Element attr_accessor :tag attr_accessor :attributes attr_accessor :mixed_content attr_accessor :raw_content attr_accessor :pattern attr_accessor :document_sync attr_accessor :empty attr_accessor :cx attr_accessor :mono attr_accessor :parser attr_accessor :type_value attr_accessor :usable attr_accessor :origin attr_accessor :copy attr_accessor :removed alias :name :tag alias :name= :tag= # # initializer (イニシャライザ) # @overload initialize(tag) # @param [String,Symbol] tag tag name (タグ名) # @overload initialize(elm) # @param [Meteor::Element] elm element (要素) # @overload initialize(elm,ps) # @param [Meteor::Element] elm element (要素) # @param [Meteor::Parser] ps parser (パーサ) # def initialize(*args) case args.length when ONE if args[0].kind_of?(String) initialize_s(args[0]) elsif args[0].kind_of?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when TWO @tag = args[0].tag @attributes = String.new(args[0].attributes) @mixed_content = String.new(args[0].mixed_content) #@pattern = String.new(args[0].pattern) @pattern = args[0].pattern @document = String.new(args[0].document) @empty = args[0].empty @cx = args[0].cx @mono = args[0].mono @parser = args[1] #@usable = false @origin = args[0] args[0].copy = self when ZERO else raise ArgumentError end end # # initializer (イニシャライザ) # @param [String] tag tag name (タグ名) # def initialize_s(tag) @tag = tag #@attributes = nil #@mixed_content = nil #@pattern = nil #@document = nil #@parser=nil #@empty = false #@cx = false #@mono = false #@parent = false @usable = true end private :initialize_s # # initializer (イニシャライザ) # @param [Meteor::Element] elm element (要素) # def initialize_e(elm) @tag = elm.tag @attributes = String.new(elm.attributes) #@pattern = String.new(elm.pattern) @pattern = elm.pattern @document = String.new(elm.document) @empty = elm.empty @cx = elm.cx @mono = elm.mono @origin = elm @parser = elm.parser @usable = true end private :initialize_e # # make copy (コピーを作成する) # @overload new!(elm,ps) # @param [Meteor::Element] elm element (要素) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def self.new!(*args) case args.length when TWO @obj = args[1].element_hook if @obj @obj.attributes = String.new(args[0].attributes) @obj.mixed_content = String.new(args[0].mixed_content) #@obj.pattern = String.new(args[0].pattern) @obj.document = String.new(args[0].document) @obj else @obj = self.new(args[0], args[1]) args[1].element_hook = @obj @obj end else raise ArgumentError end end # # clone (複製する) # @return [Meteor::Element] element (要素) # def clone obj = self.parser.element_cache[self.object_id] if obj obj.attributes = String.new(self.attributes) obj.mixed_content = String.new(self.mixed_content) #obj.pattern = String.new(self.pattern) obj.document = String.new(self.document) obj.usable = true obj else obj = self.new(self) self.parser.element_cache[self.object_id] = obj obj end end # # set document (ドキュメントをセットする) # @param [String] doc document (ドキュメント) # def document=(doc) @document_sync = false @document = doc end # # get document (ドキュメントを取得する) # @return [String] document (ドキュメント) # def document if @document_sync @document_sync = false case @parser.doc_type when Parser::HTML, Parser::HTML5 if @cx #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4 @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->" else if @empty #@pattern_cc = '' << TAG_OPEN << elm.tag << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.tag << TAG_CLOSE @document = "<#{@tag}#{@attributes}>#{@mixed_content}</#{@tag}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @tag << @attributes << Meteor::Core::Kernel::TAG_CLOSE #@document = "<#{@name}#{@attributes}>" end end when Parser::XHTML, Parser::XHTML5, Parser::XML if @cx #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4 @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->" else if @empty #@pattern_cc = '' << TAG_OPEN << elm.tag << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.tag << TAG_CLOSE @document = "<#{@tag}#{@attributes}>#{@mixed_content}</#{@tag}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @tag << @attributes << Meteor::Core::Kernel::TAG_CLOSE3 #@document = "<#{@name}#{@attributes}/>" end end end else @document end end # # get element (要素を取得する) # @overload element() # get element (要素を取得する) # @return [Meteor::Element] element (要素) # @overload element(tag) # get element using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @return [Meteor::Element] element (要素) # @overload element(tag,attrs) # get element using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element (要素) # @overload element(attrs) # get element using attribute map (属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element(要素) # @overload element(tag,attr_name,attr_value) # get element using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Meteor::Element] element (要素) # @overload element(attr_name,attr_value) # get element using attribute(name="value") (属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name 属性名 # @param [String] attr_value 属性値 # @return [Meteor::Element] element (要素) # @overload element(tag,attr_name1,attr_value1,attr_name2,attr_value2) # get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Meteor::Element] element (要素) # @overload element(attr_name1,attr_value1,attr_name2,attr_value2) # get element using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name1 属性名1 # @param [String] attr_value1 属性値1 # @param [String,Symbol] attr_name2 属性名2 # @param [String] attr_value2 属性値2 # @return [Meteor::Element] element(要素) # @overload element(elm) # mirror element (要素を射影する) # @param [Meteor::Element] elm element(要素) # @return [Meteor::Element] element(要素) # def element(elm = nil, attrs = nil,*args) #case args.length #when ZERO if !elm && !attrs @parser.element(self) else @parser.element(elm, attrs,*args) end end alias :child :element # # get elements (要素を取得する) # @overload elements(tag) # get elements using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @return [Array<Meteor::Element>] element array(要素配列) # @overload elements(tag,attrs) # get elements using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attrs) # get elements using attribute map (属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(tag,attr_name,attr_value) # get elements using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attr_name,attr_value) # get elements using attribute(name="value") (属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(tag,attr_name1,attr_value1,attr_name2,attr_value2) # get elements using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attr_name1,attr_value1,attr_name2,attr_value2) # get elements using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Array<Meteor::Element>] element array (要素配列) # def elements(*args) @parser.elements(*args) end # # get (child) elements using selector like css3(CSS3のようにセレクタを用いて(子)要素を取得する) # CSS3 selector partial support (CSS3セレクタの部分的サポート) # @param selector [String] selector (セレクタ) # @return [Array<Meteor::Element>] element (要素) # def find(selector) @parser.find(selector) end alias :css :find # # get cx(comment extension) tag (CX(コメント拡張)タグを取得する) # @overload cxtag(tag,id) # get cx(comment extension) tag using tag name and id attribute (タグ名とID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String] id id attribute value (ID属性値) # @return [Meteor::Element] element(要素) # @overload cxtag(id) # get cx(comment extension) tag using id attribute (ID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String] id id attribute value (ID属性値) # @return [Meteor::Element] element (要素) # def cxtag(*args) @parser.cxtag(*args) end # # @overload attr(attr) # set attribute of element (要素の属性をセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attr attribute (属性) # @return [Meteor::Element] element (要素) # @deprecated # @overload attr(attr_name,attr_value) # set attribute of element (要素の属性をセットする) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String,true,false] attr_value attribute value (属性値) # @return [Meteor::Element] element (要素) # @overload attr(attr_name) # get attribute value of element (要素の属性値を取得する) # @param [String,Symbol] attr_name attribute name (属性名) # @return [String] attribute value (属性値) # def attr(attrs,*args) @parser.attr(self, attrs,*args) end # # set attribute of element (要素の属性をセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attr attribute (属性) # @return [Meteor::Element] element (要素) # def attr=(attr) @parser.attr(self,attr) end # # set attribute map (要素マップをセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element (要素) def attrs=(attrs) @parser.attrs(self,attrs) end # # get attribute map (属性マップを取得する) # @return [Hash<String,String>,Hash<Symbol,String>] attribute map (属性マップ) # def attrs @parser.attrs(self) end # # @overload attr_map(attr_map) # set attribute map (属性マップをセットする) # @param [Meteor::AttributeMap] attr_map attribute map (属性マップ) # @return [Meteor::Element] element (要素) # @deprecated # @overload attr_map() # get attribute map (属性マップを取得する) # @return [Meteor::AttributeMap] attribute map (属性マップ) # def attr_map(*args) @parser.attr_map(self, *args) end # # set attribute map (属性マップをセットする) # @param [Meteor::AttributeMap] attr_map attribute map (属性マップ) # @return [Meteor::Element] element (要素) # def attr_map=(attr_map) @parser.attr_map(self,attr_map) end # # @overload content(content,entity_ref=true) # set content of element (要素の内容をセットする) # @param [String] content content of element (要素の内容) # @param [true,false] entity_ref entity reference flag (エンティティ参照フラグ) # @return [Meteor::Element] element (要素) # @deprecated # @overload content(content) # set content of element (要素の内容をセットする) # @param [String] content content of element (要素の内容) # @return [Meteor::Element] element (要素) # @deprecated # @overload content() # get content of element (要素の内容を取得する) # @return [String] content (内容) # def content(*args) @parser.content(self, *args) end # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def content=(value) @parser.content(self, value) end # # set attribute (属性をセットする) # @param [String,Symbol] name attribute name (属性の名前) # @param [String] value attribute value (属性の値) # @return [Meteor::Element] element (要素) # def []=(name, value) @parser.attr(self, name, value) end # # get attribute value (属性の値を取得する) # @param [String,Symbol] name attribute name (属性の名前) # @return [String] attribute value (属性の値) # def [](name) @parser.attr(self, name) end # # remove attribute of element (要素の属性を消す) # @param [String,Symbol] attr_name attribute name (属性名) # @return [Meteor::Element] element (要素) # def remove_attr(attr_name) @parser.remove_attr(self, attr_name) end # # remove element (要素を削除する) # def remove @parser.remove_element(self) end # # reflect (反映する) # def flush @parser.flush end # # @overload execute(hook) # run action of Hooker (Hookerクラスの処理を実行する) # @param [Meteor::Hook::Hooker] hook Hooker object (Hookerオブジェクト) # @overload execute(loop,list) # run action of Looper (Looperクラスの処理を実行する) # @param [Meteor::Hook::Looper] loop Looper object (Looperオブジェクト) # @param [Array] list 配列 # def execute(*args) @parser.execute(self, *args) end end |
#empty ⇒ true, false
Returns content empty flag (内容存在フラグ).
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
# File 'lib/meteor.rb', line 79 class Element attr_accessor :tag attr_accessor :attributes attr_accessor :mixed_content attr_accessor :raw_content attr_accessor :pattern attr_accessor :document_sync attr_accessor :empty attr_accessor :cx attr_accessor :mono attr_accessor :parser attr_accessor :type_value attr_accessor :usable attr_accessor :origin attr_accessor :copy attr_accessor :removed alias :name :tag alias :name= :tag= # # initializer (イニシャライザ) # @overload initialize(tag) # @param [String,Symbol] tag tag name (タグ名) # @overload initialize(elm) # @param [Meteor::Element] elm element (要素) # @overload initialize(elm,ps) # @param [Meteor::Element] elm element (要素) # @param [Meteor::Parser] ps parser (パーサ) # def initialize(*args) case args.length when ONE if args[0].kind_of?(String) initialize_s(args[0]) elsif args[0].kind_of?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when TWO @tag = args[0].tag @attributes = String.new(args[0].attributes) @mixed_content = String.new(args[0].mixed_content) #@pattern = String.new(args[0].pattern) @pattern = args[0].pattern @document = String.new(args[0].document) @empty = args[0].empty @cx = args[0].cx @mono = args[0].mono @parser = args[1] #@usable = false @origin = args[0] args[0].copy = self when ZERO else raise ArgumentError end end # # initializer (イニシャライザ) # @param [String] tag tag name (タグ名) # def initialize_s(tag) @tag = tag #@attributes = nil #@mixed_content = nil #@pattern = nil #@document = nil #@parser=nil #@empty = false #@cx = false #@mono = false #@parent = false @usable = true end private :initialize_s # # initializer (イニシャライザ) # @param [Meteor::Element] elm element (要素) # def initialize_e(elm) @tag = elm.tag @attributes = String.new(elm.attributes) #@pattern = String.new(elm.pattern) @pattern = elm.pattern @document = String.new(elm.document) @empty = elm.empty @cx = elm.cx @mono = elm.mono @origin = elm @parser = elm.parser @usable = true end private :initialize_e # # make copy (コピーを作成する) # @overload new!(elm,ps) # @param [Meteor::Element] elm element (要素) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def self.new!(*args) case args.length when TWO @obj = args[1].element_hook if @obj @obj.attributes = String.new(args[0].attributes) @obj.mixed_content = String.new(args[0].mixed_content) #@obj.pattern = String.new(args[0].pattern) @obj.document = String.new(args[0].document) @obj else @obj = self.new(args[0], args[1]) args[1].element_hook = @obj @obj end else raise ArgumentError end end # # clone (複製する) # @return [Meteor::Element] element (要素) # def clone obj = self.parser.element_cache[self.object_id] if obj obj.attributes = String.new(self.attributes) obj.mixed_content = String.new(self.mixed_content) #obj.pattern = String.new(self.pattern) obj.document = String.new(self.document) obj.usable = true obj else obj = self.new(self) self.parser.element_cache[self.object_id] = obj obj end end # # set document (ドキュメントをセットする) # @param [String] doc document (ドキュメント) # def document=(doc) @document_sync = false @document = doc end # # get document (ドキュメントを取得する) # @return [String] document (ドキュメント) # def document if @document_sync @document_sync = false case @parser.doc_type when Parser::HTML, Parser::HTML5 if @cx #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4 @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->" else if @empty #@pattern_cc = '' << TAG_OPEN << elm.tag << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.tag << TAG_CLOSE @document = "<#{@tag}#{@attributes}>#{@mixed_content}</#{@tag}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @tag << @attributes << Meteor::Core::Kernel::TAG_CLOSE #@document = "<#{@name}#{@attributes}>" end end when Parser::XHTML, Parser::XHTML5, Parser::XML if @cx #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4 @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->" else if @empty #@pattern_cc = '' << TAG_OPEN << elm.tag << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.tag << TAG_CLOSE @document = "<#{@tag}#{@attributes}>#{@mixed_content}</#{@tag}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @tag << @attributes << Meteor::Core::Kernel::TAG_CLOSE3 #@document = "<#{@name}#{@attributes}/>" end end end else @document end end # # get element (要素を取得する) # @overload element() # get element (要素を取得する) # @return [Meteor::Element] element (要素) # @overload element(tag) # get element using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @return [Meteor::Element] element (要素) # @overload element(tag,attrs) # get element using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element (要素) # @overload element(attrs) # get element using attribute map (属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element(要素) # @overload element(tag,attr_name,attr_value) # get element using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Meteor::Element] element (要素) # @overload element(attr_name,attr_value) # get element using attribute(name="value") (属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name 属性名 # @param [String] attr_value 属性値 # @return [Meteor::Element] element (要素) # @overload element(tag,attr_name1,attr_value1,attr_name2,attr_value2) # get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Meteor::Element] element (要素) # @overload element(attr_name1,attr_value1,attr_name2,attr_value2) # get element using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name1 属性名1 # @param [String] attr_value1 属性値1 # @param [String,Symbol] attr_name2 属性名2 # @param [String] attr_value2 属性値2 # @return [Meteor::Element] element(要素) # @overload element(elm) # mirror element (要素を射影する) # @param [Meteor::Element] elm element(要素) # @return [Meteor::Element] element(要素) # def element(elm = nil, attrs = nil,*args) #case args.length #when ZERO if !elm && !attrs @parser.element(self) else @parser.element(elm, attrs,*args) end end alias :child :element # # get elements (要素を取得する) # @overload elements(tag) # get elements using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @return [Array<Meteor::Element>] element array(要素配列) # @overload elements(tag,attrs) # get elements using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attrs) # get elements using attribute map (属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(tag,attr_name,attr_value) # get elements using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attr_name,attr_value) # get elements using attribute(name="value") (属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(tag,attr_name1,attr_value1,attr_name2,attr_value2) # get elements using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attr_name1,attr_value1,attr_name2,attr_value2) # get elements using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Array<Meteor::Element>] element array (要素配列) # def elements(*args) @parser.elements(*args) end # # get (child) elements using selector like css3(CSS3のようにセレクタを用いて(子)要素を取得する) # CSS3 selector partial support (CSS3セレクタの部分的サポート) # @param selector [String] selector (セレクタ) # @return [Array<Meteor::Element>] element (要素) # def find(selector) @parser.find(selector) end alias :css :find # # get cx(comment extension) tag (CX(コメント拡張)タグを取得する) # @overload cxtag(tag,id) # get cx(comment extension) tag using tag name and id attribute (タグ名とID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String] id id attribute value (ID属性値) # @return [Meteor::Element] element(要素) # @overload cxtag(id) # get cx(comment extension) tag using id attribute (ID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String] id id attribute value (ID属性値) # @return [Meteor::Element] element (要素) # def cxtag(*args) @parser.cxtag(*args) end # # @overload attr(attr) # set attribute of element (要素の属性をセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attr attribute (属性) # @return [Meteor::Element] element (要素) # @deprecated # @overload attr(attr_name,attr_value) # set attribute of element (要素の属性をセットする) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String,true,false] attr_value attribute value (属性値) # @return [Meteor::Element] element (要素) # @overload attr(attr_name) # get attribute value of element (要素の属性値を取得する) # @param [String,Symbol] attr_name attribute name (属性名) # @return [String] attribute value (属性値) # def attr(attrs,*args) @parser.attr(self, attrs,*args) end # # set attribute of element (要素の属性をセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attr attribute (属性) # @return [Meteor::Element] element (要素) # def attr=(attr) @parser.attr(self,attr) end # # set attribute map (要素マップをセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element (要素) def attrs=(attrs) @parser.attrs(self,attrs) end # # get attribute map (属性マップを取得する) # @return [Hash<String,String>,Hash<Symbol,String>] attribute map (属性マップ) # def attrs @parser.attrs(self) end # # @overload attr_map(attr_map) # set attribute map (属性マップをセットする) # @param [Meteor::AttributeMap] attr_map attribute map (属性マップ) # @return [Meteor::Element] element (要素) # @deprecated # @overload attr_map() # get attribute map (属性マップを取得する) # @return [Meteor::AttributeMap] attribute map (属性マップ) # def attr_map(*args) @parser.attr_map(self, *args) end # # set attribute map (属性マップをセットする) # @param [Meteor::AttributeMap] attr_map attribute map (属性マップ) # @return [Meteor::Element] element (要素) # def attr_map=(attr_map) @parser.attr_map(self,attr_map) end # # @overload content(content,entity_ref=true) # set content of element (要素の内容をセットする) # @param [String] content content of element (要素の内容) # @param [true,false] entity_ref entity reference flag (エンティティ参照フラグ) # @return [Meteor::Element] element (要素) # @deprecated # @overload content(content) # set content of element (要素の内容をセットする) # @param [String] content content of element (要素の内容) # @return [Meteor::Element] element (要素) # @deprecated # @overload content() # get content of element (要素の内容を取得する) # @return [String] content (内容) # def content(*args) @parser.content(self, *args) end # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def content=(value) @parser.content(self, value) end # # set attribute (属性をセットする) # @param [String,Symbol] name attribute name (属性の名前) # @param [String] value attribute value (属性の値) # @return [Meteor::Element] element (要素) # def []=(name, value) @parser.attr(self, name, value) end # # get attribute value (属性の値を取得する) # @param [String,Symbol] name attribute name (属性の名前) # @return [String] attribute value (属性の値) # def [](name) @parser.attr(self, name) end # # remove attribute of element (要素の属性を消す) # @param [String,Symbol] attr_name attribute name (属性名) # @return [Meteor::Element] element (要素) # def remove_attr(attr_name) @parser.remove_attr(self, attr_name) end # # remove element (要素を削除する) # def remove @parser.remove_element(self) end # # reflect (反映する) # def flush @parser.flush end # # @overload execute(hook) # run action of Hooker (Hookerクラスの処理を実行する) # @param [Meteor::Hook::Hooker] hook Hooker object (Hookerオブジェクト) # @overload execute(loop,list) # run action of Looper (Looperクラスの処理を実行する) # @param [Meteor::Hook::Looper] loop Looper object (Looperオブジェクト) # @param [Array] list 配列 # def execute(*args) @parser.execute(self, *args) end end |
#mixed_content ⇒ String
Returns content (内容).
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
# File 'lib/meteor.rb', line 79 class Element attr_accessor :tag attr_accessor :attributes attr_accessor :mixed_content attr_accessor :raw_content attr_accessor :pattern attr_accessor :document_sync attr_accessor :empty attr_accessor :cx attr_accessor :mono attr_accessor :parser attr_accessor :type_value attr_accessor :usable attr_accessor :origin attr_accessor :copy attr_accessor :removed alias :name :tag alias :name= :tag= # # initializer (イニシャライザ) # @overload initialize(tag) # @param [String,Symbol] tag tag name (タグ名) # @overload initialize(elm) # @param [Meteor::Element] elm element (要素) # @overload initialize(elm,ps) # @param [Meteor::Element] elm element (要素) # @param [Meteor::Parser] ps parser (パーサ) # def initialize(*args) case args.length when ONE if args[0].kind_of?(String) initialize_s(args[0]) elsif args[0].kind_of?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when TWO @tag = args[0].tag @attributes = String.new(args[0].attributes) @mixed_content = String.new(args[0].mixed_content) #@pattern = String.new(args[0].pattern) @pattern = args[0].pattern @document = String.new(args[0].document) @empty = args[0].empty @cx = args[0].cx @mono = args[0].mono @parser = args[1] #@usable = false @origin = args[0] args[0].copy = self when ZERO else raise ArgumentError end end # # initializer (イニシャライザ) # @param [String] tag tag name (タグ名) # def initialize_s(tag) @tag = tag #@attributes = nil #@mixed_content = nil #@pattern = nil #@document = nil #@parser=nil #@empty = false #@cx = false #@mono = false #@parent = false @usable = true end private :initialize_s # # initializer (イニシャライザ) # @param [Meteor::Element] elm element (要素) # def initialize_e(elm) @tag = elm.tag @attributes = String.new(elm.attributes) #@pattern = String.new(elm.pattern) @pattern = elm.pattern @document = String.new(elm.document) @empty = elm.empty @cx = elm.cx @mono = elm.mono @origin = elm @parser = elm.parser @usable = true end private :initialize_e # # make copy (コピーを作成する) # @overload new!(elm,ps) # @param [Meteor::Element] elm element (要素) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def self.new!(*args) case args.length when TWO @obj = args[1].element_hook if @obj @obj.attributes = String.new(args[0].attributes) @obj.mixed_content = String.new(args[0].mixed_content) #@obj.pattern = String.new(args[0].pattern) @obj.document = String.new(args[0].document) @obj else @obj = self.new(args[0], args[1]) args[1].element_hook = @obj @obj end else raise ArgumentError end end # # clone (複製する) # @return [Meteor::Element] element (要素) # def clone obj = self.parser.element_cache[self.object_id] if obj obj.attributes = String.new(self.attributes) obj.mixed_content = String.new(self.mixed_content) #obj.pattern = String.new(self.pattern) obj.document = String.new(self.document) obj.usable = true obj else obj = self.new(self) self.parser.element_cache[self.object_id] = obj obj end end # # set document (ドキュメントをセットする) # @param [String] doc document (ドキュメント) # def document=(doc) @document_sync = false @document = doc end # # get document (ドキュメントを取得する) # @return [String] document (ドキュメント) # def document if @document_sync @document_sync = false case @parser.doc_type when Parser::HTML, Parser::HTML5 if @cx #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4 @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->" else if @empty #@pattern_cc = '' << TAG_OPEN << elm.tag << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.tag << TAG_CLOSE @document = "<#{@tag}#{@attributes}>#{@mixed_content}</#{@tag}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @tag << @attributes << Meteor::Core::Kernel::TAG_CLOSE #@document = "<#{@name}#{@attributes}>" end end when Parser::XHTML, Parser::XHTML5, Parser::XML if @cx #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4 @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->" else if @empty #@pattern_cc = '' << TAG_OPEN << elm.tag << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.tag << TAG_CLOSE @document = "<#{@tag}#{@attributes}>#{@mixed_content}</#{@tag}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @tag << @attributes << Meteor::Core::Kernel::TAG_CLOSE3 #@document = "<#{@name}#{@attributes}/>" end end end else @document end end # # get element (要素を取得する) # @overload element() # get element (要素を取得する) # @return [Meteor::Element] element (要素) # @overload element(tag) # get element using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @return [Meteor::Element] element (要素) # @overload element(tag,attrs) # get element using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element (要素) # @overload element(attrs) # get element using attribute map (属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element(要素) # @overload element(tag,attr_name,attr_value) # get element using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Meteor::Element] element (要素) # @overload element(attr_name,attr_value) # get element using attribute(name="value") (属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name 属性名 # @param [String] attr_value 属性値 # @return [Meteor::Element] element (要素) # @overload element(tag,attr_name1,attr_value1,attr_name2,attr_value2) # get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Meteor::Element] element (要素) # @overload element(attr_name1,attr_value1,attr_name2,attr_value2) # get element using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name1 属性名1 # @param [String] attr_value1 属性値1 # @param [String,Symbol] attr_name2 属性名2 # @param [String] attr_value2 属性値2 # @return [Meteor::Element] element(要素) # @overload element(elm) # mirror element (要素を射影する) # @param [Meteor::Element] elm element(要素) # @return [Meteor::Element] element(要素) # def element(elm = nil, attrs = nil,*args) #case args.length #when ZERO if !elm && !attrs @parser.element(self) else @parser.element(elm, attrs,*args) end end alias :child :element # # get elements (要素を取得する) # @overload elements(tag) # get elements using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @return [Array<Meteor::Element>] element array(要素配列) # @overload elements(tag,attrs) # get elements using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attrs) # get elements using attribute map (属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(tag,attr_name,attr_value) # get elements using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attr_name,attr_value) # get elements using attribute(name="value") (属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(tag,attr_name1,attr_value1,attr_name2,attr_value2) # get elements using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attr_name1,attr_value1,attr_name2,attr_value2) # get elements using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Array<Meteor::Element>] element array (要素配列) # def elements(*args) @parser.elements(*args) end # # get (child) elements using selector like css3(CSS3のようにセレクタを用いて(子)要素を取得する) # CSS3 selector partial support (CSS3セレクタの部分的サポート) # @param selector [String] selector (セレクタ) # @return [Array<Meteor::Element>] element (要素) # def find(selector) @parser.find(selector) end alias :css :find # # get cx(comment extension) tag (CX(コメント拡張)タグを取得する) # @overload cxtag(tag,id) # get cx(comment extension) tag using tag name and id attribute (タグ名とID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String] id id attribute value (ID属性値) # @return [Meteor::Element] element(要素) # @overload cxtag(id) # get cx(comment extension) tag using id attribute (ID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String] id id attribute value (ID属性値) # @return [Meteor::Element] element (要素) # def cxtag(*args) @parser.cxtag(*args) end # # @overload attr(attr) # set attribute of element (要素の属性をセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attr attribute (属性) # @return [Meteor::Element] element (要素) # @deprecated # @overload attr(attr_name,attr_value) # set attribute of element (要素の属性をセットする) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String,true,false] attr_value attribute value (属性値) # @return [Meteor::Element] element (要素) # @overload attr(attr_name) # get attribute value of element (要素の属性値を取得する) # @param [String,Symbol] attr_name attribute name (属性名) # @return [String] attribute value (属性値) # def attr(attrs,*args) @parser.attr(self, attrs,*args) end # # set attribute of element (要素の属性をセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attr attribute (属性) # @return [Meteor::Element] element (要素) # def attr=(attr) @parser.attr(self,attr) end # # set attribute map (要素マップをセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element (要素) def attrs=(attrs) @parser.attrs(self,attrs) end # # get attribute map (属性マップを取得する) # @return [Hash<String,String>,Hash<Symbol,String>] attribute map (属性マップ) # def attrs @parser.attrs(self) end # # @overload attr_map(attr_map) # set attribute map (属性マップをセットする) # @param [Meteor::AttributeMap] attr_map attribute map (属性マップ) # @return [Meteor::Element] element (要素) # @deprecated # @overload attr_map() # get attribute map (属性マップを取得する) # @return [Meteor::AttributeMap] attribute map (属性マップ) # def attr_map(*args) @parser.attr_map(self, *args) end # # set attribute map (属性マップをセットする) # @param [Meteor::AttributeMap] attr_map attribute map (属性マップ) # @return [Meteor::Element] element (要素) # def attr_map=(attr_map) @parser.attr_map(self,attr_map) end # # @overload content(content,entity_ref=true) # set content of element (要素の内容をセットする) # @param [String] content content of element (要素の内容) # @param [true,false] entity_ref entity reference flag (エンティティ参照フラグ) # @return [Meteor::Element] element (要素) # @deprecated # @overload content(content) # set content of element (要素の内容をセットする) # @param [String] content content of element (要素の内容) # @return [Meteor::Element] element (要素) # @deprecated # @overload content() # get content of element (要素の内容を取得する) # @return [String] content (内容) # def content(*args) @parser.content(self, *args) end # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def content=(value) @parser.content(self, value) end # # set attribute (属性をセットする) # @param [String,Symbol] name attribute name (属性の名前) # @param [String] value attribute value (属性の値) # @return [Meteor::Element] element (要素) # def []=(name, value) @parser.attr(self, name, value) end # # get attribute value (属性の値を取得する) # @param [String,Symbol] name attribute name (属性の名前) # @return [String] attribute value (属性の値) # def [](name) @parser.attr(self, name) end # # remove attribute of element (要素の属性を消す) # @param [String,Symbol] attr_name attribute name (属性名) # @return [Meteor::Element] element (要素) # def remove_attr(attr_name) @parser.remove_attr(self, attr_name) end # # remove element (要素を削除する) # def remove @parser.remove_element(self) end # # reflect (反映する) # def flush @parser.flush end # # @overload execute(hook) # run action of Hooker (Hookerクラスの処理を実行する) # @param [Meteor::Hook::Hooker] hook Hooker object (Hookerオブジェクト) # @overload execute(loop,list) # run action of Looper (Looperクラスの処理を実行する) # @param [Meteor::Hook::Looper] loop Looper object (Looperオブジェクト) # @param [Array] list 配列 # def execute(*args) @parser.execute(self, *args) end end |
#mono ⇒ true, false
Returns child element existance flag (子要素存在フラグ).
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
# File 'lib/meteor.rb', line 79 class Element attr_accessor :tag attr_accessor :attributes attr_accessor :mixed_content attr_accessor :raw_content attr_accessor :pattern attr_accessor :document_sync attr_accessor :empty attr_accessor :cx attr_accessor :mono attr_accessor :parser attr_accessor :type_value attr_accessor :usable attr_accessor :origin attr_accessor :copy attr_accessor :removed alias :name :tag alias :name= :tag= # # initializer (イニシャライザ) # @overload initialize(tag) # @param [String,Symbol] tag tag name (タグ名) # @overload initialize(elm) # @param [Meteor::Element] elm element (要素) # @overload initialize(elm,ps) # @param [Meteor::Element] elm element (要素) # @param [Meteor::Parser] ps parser (パーサ) # def initialize(*args) case args.length when ONE if args[0].kind_of?(String) initialize_s(args[0]) elsif args[0].kind_of?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when TWO @tag = args[0].tag @attributes = String.new(args[0].attributes) @mixed_content = String.new(args[0].mixed_content) #@pattern = String.new(args[0].pattern) @pattern = args[0].pattern @document = String.new(args[0].document) @empty = args[0].empty @cx = args[0].cx @mono = args[0].mono @parser = args[1] #@usable = false @origin = args[0] args[0].copy = self when ZERO else raise ArgumentError end end # # initializer (イニシャライザ) # @param [String] tag tag name (タグ名) # def initialize_s(tag) @tag = tag #@attributes = nil #@mixed_content = nil #@pattern = nil #@document = nil #@parser=nil #@empty = false #@cx = false #@mono = false #@parent = false @usable = true end private :initialize_s # # initializer (イニシャライザ) # @param [Meteor::Element] elm element (要素) # def initialize_e(elm) @tag = elm.tag @attributes = String.new(elm.attributes) #@pattern = String.new(elm.pattern) @pattern = elm.pattern @document = String.new(elm.document) @empty = elm.empty @cx = elm.cx @mono = elm.mono @origin = elm @parser = elm.parser @usable = true end private :initialize_e # # make copy (コピーを作成する) # @overload new!(elm,ps) # @param [Meteor::Element] elm element (要素) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def self.new!(*args) case args.length when TWO @obj = args[1].element_hook if @obj @obj.attributes = String.new(args[0].attributes) @obj.mixed_content = String.new(args[0].mixed_content) #@obj.pattern = String.new(args[0].pattern) @obj.document = String.new(args[0].document) @obj else @obj = self.new(args[0], args[1]) args[1].element_hook = @obj @obj end else raise ArgumentError end end # # clone (複製する) # @return [Meteor::Element] element (要素) # def clone obj = self.parser.element_cache[self.object_id] if obj obj.attributes = String.new(self.attributes) obj.mixed_content = String.new(self.mixed_content) #obj.pattern = String.new(self.pattern) obj.document = String.new(self.document) obj.usable = true obj else obj = self.new(self) self.parser.element_cache[self.object_id] = obj obj end end # # set document (ドキュメントをセットする) # @param [String] doc document (ドキュメント) # def document=(doc) @document_sync = false @document = doc end # # get document (ドキュメントを取得する) # @return [String] document (ドキュメント) # def document if @document_sync @document_sync = false case @parser.doc_type when Parser::HTML, Parser::HTML5 if @cx #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4 @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->" else if @empty #@pattern_cc = '' << TAG_OPEN << elm.tag << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.tag << TAG_CLOSE @document = "<#{@tag}#{@attributes}>#{@mixed_content}</#{@tag}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @tag << @attributes << Meteor::Core::Kernel::TAG_CLOSE #@document = "<#{@name}#{@attributes}>" end end when Parser::XHTML, Parser::XHTML5, Parser::XML if @cx #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4 @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->" else if @empty #@pattern_cc = '' << TAG_OPEN << elm.tag << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.tag << TAG_CLOSE @document = "<#{@tag}#{@attributes}>#{@mixed_content}</#{@tag}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @tag << @attributes << Meteor::Core::Kernel::TAG_CLOSE3 #@document = "<#{@name}#{@attributes}/>" end end end else @document end end # # get element (要素を取得する) # @overload element() # get element (要素を取得する) # @return [Meteor::Element] element (要素) # @overload element(tag) # get element using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @return [Meteor::Element] element (要素) # @overload element(tag,attrs) # get element using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element (要素) # @overload element(attrs) # get element using attribute map (属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element(要素) # @overload element(tag,attr_name,attr_value) # get element using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Meteor::Element] element (要素) # @overload element(attr_name,attr_value) # get element using attribute(name="value") (属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name 属性名 # @param [String] attr_value 属性値 # @return [Meteor::Element] element (要素) # @overload element(tag,attr_name1,attr_value1,attr_name2,attr_value2) # get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Meteor::Element] element (要素) # @overload element(attr_name1,attr_value1,attr_name2,attr_value2) # get element using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name1 属性名1 # @param [String] attr_value1 属性値1 # @param [String,Symbol] attr_name2 属性名2 # @param [String] attr_value2 属性値2 # @return [Meteor::Element] element(要素) # @overload element(elm) # mirror element (要素を射影する) # @param [Meteor::Element] elm element(要素) # @return [Meteor::Element] element(要素) # def element(elm = nil, attrs = nil,*args) #case args.length #when ZERO if !elm && !attrs @parser.element(self) else @parser.element(elm, attrs,*args) end end alias :child :element # # get elements (要素を取得する) # @overload elements(tag) # get elements using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @return [Array<Meteor::Element>] element array(要素配列) # @overload elements(tag,attrs) # get elements using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attrs) # get elements using attribute map (属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(tag,attr_name,attr_value) # get elements using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attr_name,attr_value) # get elements using attribute(name="value") (属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(tag,attr_name1,attr_value1,attr_name2,attr_value2) # get elements using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attr_name1,attr_value1,attr_name2,attr_value2) # get elements using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Array<Meteor::Element>] element array (要素配列) # def elements(*args) @parser.elements(*args) end # # get (child) elements using selector like css3(CSS3のようにセレクタを用いて(子)要素を取得する) # CSS3 selector partial support (CSS3セレクタの部分的サポート) # @param selector [String] selector (セレクタ) # @return [Array<Meteor::Element>] element (要素) # def find(selector) @parser.find(selector) end alias :css :find # # get cx(comment extension) tag (CX(コメント拡張)タグを取得する) # @overload cxtag(tag,id) # get cx(comment extension) tag using tag name and id attribute (タグ名とID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String] id id attribute value (ID属性値) # @return [Meteor::Element] element(要素) # @overload cxtag(id) # get cx(comment extension) tag using id attribute (ID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String] id id attribute value (ID属性値) # @return [Meteor::Element] element (要素) # def cxtag(*args) @parser.cxtag(*args) end # # @overload attr(attr) # set attribute of element (要素の属性をセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attr attribute (属性) # @return [Meteor::Element] element (要素) # @deprecated # @overload attr(attr_name,attr_value) # set attribute of element (要素の属性をセットする) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String,true,false] attr_value attribute value (属性値) # @return [Meteor::Element] element (要素) # @overload attr(attr_name) # get attribute value of element (要素の属性値を取得する) # @param [String,Symbol] attr_name attribute name (属性名) # @return [String] attribute value (属性値) # def attr(attrs,*args) @parser.attr(self, attrs,*args) end # # set attribute of element (要素の属性をセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attr attribute (属性) # @return [Meteor::Element] element (要素) # def attr=(attr) @parser.attr(self,attr) end # # set attribute map (要素マップをセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element (要素) def attrs=(attrs) @parser.attrs(self,attrs) end # # get attribute map (属性マップを取得する) # @return [Hash<String,String>,Hash<Symbol,String>] attribute map (属性マップ) # def attrs @parser.attrs(self) end # # @overload attr_map(attr_map) # set attribute map (属性マップをセットする) # @param [Meteor::AttributeMap] attr_map attribute map (属性マップ) # @return [Meteor::Element] element (要素) # @deprecated # @overload attr_map() # get attribute map (属性マップを取得する) # @return [Meteor::AttributeMap] attribute map (属性マップ) # def attr_map(*args) @parser.attr_map(self, *args) end # # set attribute map (属性マップをセットする) # @param [Meteor::AttributeMap] attr_map attribute map (属性マップ) # @return [Meteor::Element] element (要素) # def attr_map=(attr_map) @parser.attr_map(self,attr_map) end # # @overload content(content,entity_ref=true) # set content of element (要素の内容をセットする) # @param [String] content content of element (要素の内容) # @param [true,false] entity_ref entity reference flag (エンティティ参照フラグ) # @return [Meteor::Element] element (要素) # @deprecated # @overload content(content) # set content of element (要素の内容をセットする) # @param [String] content content of element (要素の内容) # @return [Meteor::Element] element (要素) # @deprecated # @overload content() # get content of element (要素の内容を取得する) # @return [String] content (内容) # def content(*args) @parser.content(self, *args) end # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def content=(value) @parser.content(self, value) end # # set attribute (属性をセットする) # @param [String,Symbol] name attribute name (属性の名前) # @param [String] value attribute value (属性の値) # @return [Meteor::Element] element (要素) # def []=(name, value) @parser.attr(self, name, value) end # # get attribute value (属性の値を取得する) # @param [String,Symbol] name attribute name (属性の名前) # @return [String] attribute value (属性の値) # def [](name) @parser.attr(self, name) end # # remove attribute of element (要素の属性を消す) # @param [String,Symbol] attr_name attribute name (属性名) # @return [Meteor::Element] element (要素) # def remove_attr(attr_name) @parser.remove_attr(self, attr_name) end # # remove element (要素を削除する) # def remove @parser.remove_element(self) end # # reflect (反映する) # def flush @parser.flush end # # @overload execute(hook) # run action of Hooker (Hookerクラスの処理を実行する) # @param [Meteor::Hook::Hooker] hook Hooker object (Hookerオブジェクト) # @overload execute(loop,list) # run action of Looper (Looperクラスの処理を実行する) # @param [Meteor::Hook::Looper] loop Looper object (Looperオブジェクト) # @param [Array] list 配列 # def execute(*args) @parser.execute(self, *args) end end |
#origin ⇒ Meteor::Element
Returns original pointer (原本ポインタ).
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
# File 'lib/meteor.rb', line 79 class Element attr_accessor :tag attr_accessor :attributes attr_accessor :mixed_content attr_accessor :raw_content attr_accessor :pattern attr_accessor :document_sync attr_accessor :empty attr_accessor :cx attr_accessor :mono attr_accessor :parser attr_accessor :type_value attr_accessor :usable attr_accessor :origin attr_accessor :copy attr_accessor :removed alias :name :tag alias :name= :tag= # # initializer (イニシャライザ) # @overload initialize(tag) # @param [String,Symbol] tag tag name (タグ名) # @overload initialize(elm) # @param [Meteor::Element] elm element (要素) # @overload initialize(elm,ps) # @param [Meteor::Element] elm element (要素) # @param [Meteor::Parser] ps parser (パーサ) # def initialize(*args) case args.length when ONE if args[0].kind_of?(String) initialize_s(args[0]) elsif args[0].kind_of?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when TWO @tag = args[0].tag @attributes = String.new(args[0].attributes) @mixed_content = String.new(args[0].mixed_content) #@pattern = String.new(args[0].pattern) @pattern = args[0].pattern @document = String.new(args[0].document) @empty = args[0].empty @cx = args[0].cx @mono = args[0].mono @parser = args[1] #@usable = false @origin = args[0] args[0].copy = self when ZERO else raise ArgumentError end end # # initializer (イニシャライザ) # @param [String] tag tag name (タグ名) # def initialize_s(tag) @tag = tag #@attributes = nil #@mixed_content = nil #@pattern = nil #@document = nil #@parser=nil #@empty = false #@cx = false #@mono = false #@parent = false @usable = true end private :initialize_s # # initializer (イニシャライザ) # @param [Meteor::Element] elm element (要素) # def initialize_e(elm) @tag = elm.tag @attributes = String.new(elm.attributes) #@pattern = String.new(elm.pattern) @pattern = elm.pattern @document = String.new(elm.document) @empty = elm.empty @cx = elm.cx @mono = elm.mono @origin = elm @parser = elm.parser @usable = true end private :initialize_e # # make copy (コピーを作成する) # @overload new!(elm,ps) # @param [Meteor::Element] elm element (要素) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def self.new!(*args) case args.length when TWO @obj = args[1].element_hook if @obj @obj.attributes = String.new(args[0].attributes) @obj.mixed_content = String.new(args[0].mixed_content) #@obj.pattern = String.new(args[0].pattern) @obj.document = String.new(args[0].document) @obj else @obj = self.new(args[0], args[1]) args[1].element_hook = @obj @obj end else raise ArgumentError end end # # clone (複製する) # @return [Meteor::Element] element (要素) # def clone obj = self.parser.element_cache[self.object_id] if obj obj.attributes = String.new(self.attributes) obj.mixed_content = String.new(self.mixed_content) #obj.pattern = String.new(self.pattern) obj.document = String.new(self.document) obj.usable = true obj else obj = self.new(self) self.parser.element_cache[self.object_id] = obj obj end end # # set document (ドキュメントをセットする) # @param [String] doc document (ドキュメント) # def document=(doc) @document_sync = false @document = doc end # # get document (ドキュメントを取得する) # @return [String] document (ドキュメント) # def document if @document_sync @document_sync = false case @parser.doc_type when Parser::HTML, Parser::HTML5 if @cx #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4 @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->" else if @empty #@pattern_cc = '' << TAG_OPEN << elm.tag << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.tag << TAG_CLOSE @document = "<#{@tag}#{@attributes}>#{@mixed_content}</#{@tag}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @tag << @attributes << Meteor::Core::Kernel::TAG_CLOSE #@document = "<#{@name}#{@attributes}>" end end when Parser::XHTML, Parser::XHTML5, Parser::XML if @cx #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4 @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->" else if @empty #@pattern_cc = '' << TAG_OPEN << elm.tag << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.tag << TAG_CLOSE @document = "<#{@tag}#{@attributes}>#{@mixed_content}</#{@tag}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @tag << @attributes << Meteor::Core::Kernel::TAG_CLOSE3 #@document = "<#{@name}#{@attributes}/>" end end end else @document end end # # get element (要素を取得する) # @overload element() # get element (要素を取得する) # @return [Meteor::Element] element (要素) # @overload element(tag) # get element using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @return [Meteor::Element] element (要素) # @overload element(tag,attrs) # get element using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element (要素) # @overload element(attrs) # get element using attribute map (属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element(要素) # @overload element(tag,attr_name,attr_value) # get element using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Meteor::Element] element (要素) # @overload element(attr_name,attr_value) # get element using attribute(name="value") (属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name 属性名 # @param [String] attr_value 属性値 # @return [Meteor::Element] element (要素) # @overload element(tag,attr_name1,attr_value1,attr_name2,attr_value2) # get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Meteor::Element] element (要素) # @overload element(attr_name1,attr_value1,attr_name2,attr_value2) # get element using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name1 属性名1 # @param [String] attr_value1 属性値1 # @param [String,Symbol] attr_name2 属性名2 # @param [String] attr_value2 属性値2 # @return [Meteor::Element] element(要素) # @overload element(elm) # mirror element (要素を射影する) # @param [Meteor::Element] elm element(要素) # @return [Meteor::Element] element(要素) # def element(elm = nil, attrs = nil,*args) #case args.length #when ZERO if !elm && !attrs @parser.element(self) else @parser.element(elm, attrs,*args) end end alias :child :element # # get elements (要素を取得する) # @overload elements(tag) # get elements using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @return [Array<Meteor::Element>] element array(要素配列) # @overload elements(tag,attrs) # get elements using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attrs) # get elements using attribute map (属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(tag,attr_name,attr_value) # get elements using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attr_name,attr_value) # get elements using attribute(name="value") (属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(tag,attr_name1,attr_value1,attr_name2,attr_value2) # get elements using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attr_name1,attr_value1,attr_name2,attr_value2) # get elements using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Array<Meteor::Element>] element array (要素配列) # def elements(*args) @parser.elements(*args) end # # get (child) elements using selector like css3(CSS3のようにセレクタを用いて(子)要素を取得する) # CSS3 selector partial support (CSS3セレクタの部分的サポート) # @param selector [String] selector (セレクタ) # @return [Array<Meteor::Element>] element (要素) # def find(selector) @parser.find(selector) end alias :css :find # # get cx(comment extension) tag (CX(コメント拡張)タグを取得する) # @overload cxtag(tag,id) # get cx(comment extension) tag using tag name and id attribute (タグ名とID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String] id id attribute value (ID属性値) # @return [Meteor::Element] element(要素) # @overload cxtag(id) # get cx(comment extension) tag using id attribute (ID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String] id id attribute value (ID属性値) # @return [Meteor::Element] element (要素) # def cxtag(*args) @parser.cxtag(*args) end # # @overload attr(attr) # set attribute of element (要素の属性をセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attr attribute (属性) # @return [Meteor::Element] element (要素) # @deprecated # @overload attr(attr_name,attr_value) # set attribute of element (要素の属性をセットする) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String,true,false] attr_value attribute value (属性値) # @return [Meteor::Element] element (要素) # @overload attr(attr_name) # get attribute value of element (要素の属性値を取得する) # @param [String,Symbol] attr_name attribute name (属性名) # @return [String] attribute value (属性値) # def attr(attrs,*args) @parser.attr(self, attrs,*args) end # # set attribute of element (要素の属性をセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attr attribute (属性) # @return [Meteor::Element] element (要素) # def attr=(attr) @parser.attr(self,attr) end # # set attribute map (要素マップをセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element (要素) def attrs=(attrs) @parser.attrs(self,attrs) end # # get attribute map (属性マップを取得する) # @return [Hash<String,String>,Hash<Symbol,String>] attribute map (属性マップ) # def attrs @parser.attrs(self) end # # @overload attr_map(attr_map) # set attribute map (属性マップをセットする) # @param [Meteor::AttributeMap] attr_map attribute map (属性マップ) # @return [Meteor::Element] element (要素) # @deprecated # @overload attr_map() # get attribute map (属性マップを取得する) # @return [Meteor::AttributeMap] attribute map (属性マップ) # def attr_map(*args) @parser.attr_map(self, *args) end # # set attribute map (属性マップをセットする) # @param [Meteor::AttributeMap] attr_map attribute map (属性マップ) # @return [Meteor::Element] element (要素) # def attr_map=(attr_map) @parser.attr_map(self,attr_map) end # # @overload content(content,entity_ref=true) # set content of element (要素の内容をセットする) # @param [String] content content of element (要素の内容) # @param [true,false] entity_ref entity reference flag (エンティティ参照フラグ) # @return [Meteor::Element] element (要素) # @deprecated # @overload content(content) # set content of element (要素の内容をセットする) # @param [String] content content of element (要素の内容) # @return [Meteor::Element] element (要素) # @deprecated # @overload content() # get content of element (要素の内容を取得する) # @return [String] content (内容) # def content(*args) @parser.content(self, *args) end # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def content=(value) @parser.content(self, value) end # # set attribute (属性をセットする) # @param [String,Symbol] name attribute name (属性の名前) # @param [String] value attribute value (属性の値) # @return [Meteor::Element] element (要素) # def []=(name, value) @parser.attr(self, name, value) end # # get attribute value (属性の値を取得する) # @param [String,Symbol] name attribute name (属性の名前) # @return [String] attribute value (属性の値) # def [](name) @parser.attr(self, name) end # # remove attribute of element (要素の属性を消す) # @param [String,Symbol] attr_name attribute name (属性名) # @return [Meteor::Element] element (要素) # def remove_attr(attr_name) @parser.remove_attr(self, attr_name) end # # remove element (要素を削除する) # def remove @parser.remove_element(self) end # # reflect (反映する) # def flush @parser.flush end # # @overload execute(hook) # run action of Hooker (Hookerクラスの処理を実行する) # @param [Meteor::Hook::Hooker] hook Hooker object (Hookerオブジェクト) # @overload execute(loop,list) # run action of Looper (Looperクラスの処理を実行する) # @param [Meteor::Hook::Looper] loop Looper object (Looperオブジェクト) # @param [Array] list 配列 # def execute(*args) @parser.execute(self, *args) end end |
#parser ⇒ Meteor::Parser
Returns parser(パーサ).
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
# File 'lib/meteor.rb', line 79 class Element attr_accessor :tag attr_accessor :attributes attr_accessor :mixed_content attr_accessor :raw_content attr_accessor :pattern attr_accessor :document_sync attr_accessor :empty attr_accessor :cx attr_accessor :mono attr_accessor :parser attr_accessor :type_value attr_accessor :usable attr_accessor :origin attr_accessor :copy attr_accessor :removed alias :name :tag alias :name= :tag= # # initializer (イニシャライザ) # @overload initialize(tag) # @param [String,Symbol] tag tag name (タグ名) # @overload initialize(elm) # @param [Meteor::Element] elm element (要素) # @overload initialize(elm,ps) # @param [Meteor::Element] elm element (要素) # @param [Meteor::Parser] ps parser (パーサ) # def initialize(*args) case args.length when ONE if args[0].kind_of?(String) initialize_s(args[0]) elsif args[0].kind_of?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when TWO @tag = args[0].tag @attributes = String.new(args[0].attributes) @mixed_content = String.new(args[0].mixed_content) #@pattern = String.new(args[0].pattern) @pattern = args[0].pattern @document = String.new(args[0].document) @empty = args[0].empty @cx = args[0].cx @mono = args[0].mono @parser = args[1] #@usable = false @origin = args[0] args[0].copy = self when ZERO else raise ArgumentError end end # # initializer (イニシャライザ) # @param [String] tag tag name (タグ名) # def initialize_s(tag) @tag = tag #@attributes = nil #@mixed_content = nil #@pattern = nil #@document = nil #@parser=nil #@empty = false #@cx = false #@mono = false #@parent = false @usable = true end private :initialize_s # # initializer (イニシャライザ) # @param [Meteor::Element] elm element (要素) # def initialize_e(elm) @tag = elm.tag @attributes = String.new(elm.attributes) #@pattern = String.new(elm.pattern) @pattern = elm.pattern @document = String.new(elm.document) @empty = elm.empty @cx = elm.cx @mono = elm.mono @origin = elm @parser = elm.parser @usable = true end private :initialize_e # # make copy (コピーを作成する) # @overload new!(elm,ps) # @param [Meteor::Element] elm element (要素) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def self.new!(*args) case args.length when TWO @obj = args[1].element_hook if @obj @obj.attributes = String.new(args[0].attributes) @obj.mixed_content = String.new(args[0].mixed_content) #@obj.pattern = String.new(args[0].pattern) @obj.document = String.new(args[0].document) @obj else @obj = self.new(args[0], args[1]) args[1].element_hook = @obj @obj end else raise ArgumentError end end # # clone (複製する) # @return [Meteor::Element] element (要素) # def clone obj = self.parser.element_cache[self.object_id] if obj obj.attributes = String.new(self.attributes) obj.mixed_content = String.new(self.mixed_content) #obj.pattern = String.new(self.pattern) obj.document = String.new(self.document) obj.usable = true obj else obj = self.new(self) self.parser.element_cache[self.object_id] = obj obj end end # # set document (ドキュメントをセットする) # @param [String] doc document (ドキュメント) # def document=(doc) @document_sync = false @document = doc end # # get document (ドキュメントを取得する) # @return [String] document (ドキュメント) # def document if @document_sync @document_sync = false case @parser.doc_type when Parser::HTML, Parser::HTML5 if @cx #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4 @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->" else if @empty #@pattern_cc = '' << TAG_OPEN << elm.tag << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.tag << TAG_CLOSE @document = "<#{@tag}#{@attributes}>#{@mixed_content}</#{@tag}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @tag << @attributes << Meteor::Core::Kernel::TAG_CLOSE #@document = "<#{@name}#{@attributes}>" end end when Parser::XHTML, Parser::XHTML5, Parser::XML if @cx #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4 @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->" else if @empty #@pattern_cc = '' << TAG_OPEN << elm.tag << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.tag << TAG_CLOSE @document = "<#{@tag}#{@attributes}>#{@mixed_content}</#{@tag}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @tag << @attributes << Meteor::Core::Kernel::TAG_CLOSE3 #@document = "<#{@name}#{@attributes}/>" end end end else @document end end # # get element (要素を取得する) # @overload element() # get element (要素を取得する) # @return [Meteor::Element] element (要素) # @overload element(tag) # get element using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @return [Meteor::Element] element (要素) # @overload element(tag,attrs) # get element using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element (要素) # @overload element(attrs) # get element using attribute map (属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element(要素) # @overload element(tag,attr_name,attr_value) # get element using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Meteor::Element] element (要素) # @overload element(attr_name,attr_value) # get element using attribute(name="value") (属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name 属性名 # @param [String] attr_value 属性値 # @return [Meteor::Element] element (要素) # @overload element(tag,attr_name1,attr_value1,attr_name2,attr_value2) # get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Meteor::Element] element (要素) # @overload element(attr_name1,attr_value1,attr_name2,attr_value2) # get element using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name1 属性名1 # @param [String] attr_value1 属性値1 # @param [String,Symbol] attr_name2 属性名2 # @param [String] attr_value2 属性値2 # @return [Meteor::Element] element(要素) # @overload element(elm) # mirror element (要素を射影する) # @param [Meteor::Element] elm element(要素) # @return [Meteor::Element] element(要素) # def element(elm = nil, attrs = nil,*args) #case args.length #when ZERO if !elm && !attrs @parser.element(self) else @parser.element(elm, attrs,*args) end end alias :child :element # # get elements (要素を取得する) # @overload elements(tag) # get elements using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @return [Array<Meteor::Element>] element array(要素配列) # @overload elements(tag,attrs) # get elements using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attrs) # get elements using attribute map (属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(tag,attr_name,attr_value) # get elements using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attr_name,attr_value) # get elements using attribute(name="value") (属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(tag,attr_name1,attr_value1,attr_name2,attr_value2) # get elements using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attr_name1,attr_value1,attr_name2,attr_value2) # get elements using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Array<Meteor::Element>] element array (要素配列) # def elements(*args) @parser.elements(*args) end # # get (child) elements using selector like css3(CSS3のようにセレクタを用いて(子)要素を取得する) # CSS3 selector partial support (CSS3セレクタの部分的サポート) # @param selector [String] selector (セレクタ) # @return [Array<Meteor::Element>] element (要素) # def find(selector) @parser.find(selector) end alias :css :find # # get cx(comment extension) tag (CX(コメント拡張)タグを取得する) # @overload cxtag(tag,id) # get cx(comment extension) tag using tag name and id attribute (タグ名とID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String] id id attribute value (ID属性値) # @return [Meteor::Element] element(要素) # @overload cxtag(id) # get cx(comment extension) tag using id attribute (ID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String] id id attribute value (ID属性値) # @return [Meteor::Element] element (要素) # def cxtag(*args) @parser.cxtag(*args) end # # @overload attr(attr) # set attribute of element (要素の属性をセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attr attribute (属性) # @return [Meteor::Element] element (要素) # @deprecated # @overload attr(attr_name,attr_value) # set attribute of element (要素の属性をセットする) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String,true,false] attr_value attribute value (属性値) # @return [Meteor::Element] element (要素) # @overload attr(attr_name) # get attribute value of element (要素の属性値を取得する) # @param [String,Symbol] attr_name attribute name (属性名) # @return [String] attribute value (属性値) # def attr(attrs,*args) @parser.attr(self, attrs,*args) end # # set attribute of element (要素の属性をセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attr attribute (属性) # @return [Meteor::Element] element (要素) # def attr=(attr) @parser.attr(self,attr) end # # set attribute map (要素マップをセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element (要素) def attrs=(attrs) @parser.attrs(self,attrs) end # # get attribute map (属性マップを取得する) # @return [Hash<String,String>,Hash<Symbol,String>] attribute map (属性マップ) # def attrs @parser.attrs(self) end # # @overload attr_map(attr_map) # set attribute map (属性マップをセットする) # @param [Meteor::AttributeMap] attr_map attribute map (属性マップ) # @return [Meteor::Element] element (要素) # @deprecated # @overload attr_map() # get attribute map (属性マップを取得する) # @return [Meteor::AttributeMap] attribute map (属性マップ) # def attr_map(*args) @parser.attr_map(self, *args) end # # set attribute map (属性マップをセットする) # @param [Meteor::AttributeMap] attr_map attribute map (属性マップ) # @return [Meteor::Element] element (要素) # def attr_map=(attr_map) @parser.attr_map(self,attr_map) end # # @overload content(content,entity_ref=true) # set content of element (要素の内容をセットする) # @param [String] content content of element (要素の内容) # @param [true,false] entity_ref entity reference flag (エンティティ参照フラグ) # @return [Meteor::Element] element (要素) # @deprecated # @overload content(content) # set content of element (要素の内容をセットする) # @param [String] content content of element (要素の内容) # @return [Meteor::Element] element (要素) # @deprecated # @overload content() # get content of element (要素の内容を取得する) # @return [String] content (内容) # def content(*args) @parser.content(self, *args) end # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def content=(value) @parser.content(self, value) end # # set attribute (属性をセットする) # @param [String,Symbol] name attribute name (属性の名前) # @param [String] value attribute value (属性の値) # @return [Meteor::Element] element (要素) # def []=(name, value) @parser.attr(self, name, value) end # # get attribute value (属性の値を取得する) # @param [String,Symbol] name attribute name (属性の名前) # @return [String] attribute value (属性の値) # def [](name) @parser.attr(self, name) end # # remove attribute of element (要素の属性を消す) # @param [String,Symbol] attr_name attribute name (属性名) # @return [Meteor::Element] element (要素) # def remove_attr(attr_name) @parser.remove_attr(self, attr_name) end # # remove element (要素を削除する) # def remove @parser.remove_element(self) end # # reflect (反映する) # def flush @parser.flush end # # @overload execute(hook) # run action of Hooker (Hookerクラスの処理を実行する) # @param [Meteor::Hook::Hooker] hook Hooker object (Hookerオブジェクト) # @overload execute(loop,list) # run action of Looper (Looperクラスの処理を実行する) # @param [Meteor::Hook::Looper] loop Looper object (Looperオブジェクト) # @param [Array] list 配列 # def execute(*args) @parser.execute(self, *args) end end |
#pattern ⇒ String
Returns pattern (パターン).
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
# File 'lib/meteor.rb', line 79 class Element attr_accessor :tag attr_accessor :attributes attr_accessor :mixed_content attr_accessor :raw_content attr_accessor :pattern attr_accessor :document_sync attr_accessor :empty attr_accessor :cx attr_accessor :mono attr_accessor :parser attr_accessor :type_value attr_accessor :usable attr_accessor :origin attr_accessor :copy attr_accessor :removed alias :name :tag alias :name= :tag= # # initializer (イニシャライザ) # @overload initialize(tag) # @param [String,Symbol] tag tag name (タグ名) # @overload initialize(elm) # @param [Meteor::Element] elm element (要素) # @overload initialize(elm,ps) # @param [Meteor::Element] elm element (要素) # @param [Meteor::Parser] ps parser (パーサ) # def initialize(*args) case args.length when ONE if args[0].kind_of?(String) initialize_s(args[0]) elsif args[0].kind_of?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when TWO @tag = args[0].tag @attributes = String.new(args[0].attributes) @mixed_content = String.new(args[0].mixed_content) #@pattern = String.new(args[0].pattern) @pattern = args[0].pattern @document = String.new(args[0].document) @empty = args[0].empty @cx = args[0].cx @mono = args[0].mono @parser = args[1] #@usable = false @origin = args[0] args[0].copy = self when ZERO else raise ArgumentError end end # # initializer (イニシャライザ) # @param [String] tag tag name (タグ名) # def initialize_s(tag) @tag = tag #@attributes = nil #@mixed_content = nil #@pattern = nil #@document = nil #@parser=nil #@empty = false #@cx = false #@mono = false #@parent = false @usable = true end private :initialize_s # # initializer (イニシャライザ) # @param [Meteor::Element] elm element (要素) # def initialize_e(elm) @tag = elm.tag @attributes = String.new(elm.attributes) #@pattern = String.new(elm.pattern) @pattern = elm.pattern @document = String.new(elm.document) @empty = elm.empty @cx = elm.cx @mono = elm.mono @origin = elm @parser = elm.parser @usable = true end private :initialize_e # # make copy (コピーを作成する) # @overload new!(elm,ps) # @param [Meteor::Element] elm element (要素) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def self.new!(*args) case args.length when TWO @obj = args[1].element_hook if @obj @obj.attributes = String.new(args[0].attributes) @obj.mixed_content = String.new(args[0].mixed_content) #@obj.pattern = String.new(args[0].pattern) @obj.document = String.new(args[0].document) @obj else @obj = self.new(args[0], args[1]) args[1].element_hook = @obj @obj end else raise ArgumentError end end # # clone (複製する) # @return [Meteor::Element] element (要素) # def clone obj = self.parser.element_cache[self.object_id] if obj obj.attributes = String.new(self.attributes) obj.mixed_content = String.new(self.mixed_content) #obj.pattern = String.new(self.pattern) obj.document = String.new(self.document) obj.usable = true obj else obj = self.new(self) self.parser.element_cache[self.object_id] = obj obj end end # # set document (ドキュメントをセットする) # @param [String] doc document (ドキュメント) # def document=(doc) @document_sync = false @document = doc end # # get document (ドキュメントを取得する) # @return [String] document (ドキュメント) # def document if @document_sync @document_sync = false case @parser.doc_type when Parser::HTML, Parser::HTML5 if @cx #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4 @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->" else if @empty #@pattern_cc = '' << TAG_OPEN << elm.tag << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.tag << TAG_CLOSE @document = "<#{@tag}#{@attributes}>#{@mixed_content}</#{@tag}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @tag << @attributes << Meteor::Core::Kernel::TAG_CLOSE #@document = "<#{@name}#{@attributes}>" end end when Parser::XHTML, Parser::XHTML5, Parser::XML if @cx #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4 @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->" else if @empty #@pattern_cc = '' << TAG_OPEN << elm.tag << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.tag << TAG_CLOSE @document = "<#{@tag}#{@attributes}>#{@mixed_content}</#{@tag}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @tag << @attributes << Meteor::Core::Kernel::TAG_CLOSE3 #@document = "<#{@name}#{@attributes}/>" end end end else @document end end # # get element (要素を取得する) # @overload element() # get element (要素を取得する) # @return [Meteor::Element] element (要素) # @overload element(tag) # get element using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @return [Meteor::Element] element (要素) # @overload element(tag,attrs) # get element using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element (要素) # @overload element(attrs) # get element using attribute map (属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element(要素) # @overload element(tag,attr_name,attr_value) # get element using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Meteor::Element] element (要素) # @overload element(attr_name,attr_value) # get element using attribute(name="value") (属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name 属性名 # @param [String] attr_value 属性値 # @return [Meteor::Element] element (要素) # @overload element(tag,attr_name1,attr_value1,attr_name2,attr_value2) # get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Meteor::Element] element (要素) # @overload element(attr_name1,attr_value1,attr_name2,attr_value2) # get element using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name1 属性名1 # @param [String] attr_value1 属性値1 # @param [String,Symbol] attr_name2 属性名2 # @param [String] attr_value2 属性値2 # @return [Meteor::Element] element(要素) # @overload element(elm) # mirror element (要素を射影する) # @param [Meteor::Element] elm element(要素) # @return [Meteor::Element] element(要素) # def element(elm = nil, attrs = nil,*args) #case args.length #when ZERO if !elm && !attrs @parser.element(self) else @parser.element(elm, attrs,*args) end end alias :child :element # # get elements (要素を取得する) # @overload elements(tag) # get elements using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @return [Array<Meteor::Element>] element array(要素配列) # @overload elements(tag,attrs) # get elements using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attrs) # get elements using attribute map (属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(tag,attr_name,attr_value) # get elements using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attr_name,attr_value) # get elements using attribute(name="value") (属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(tag,attr_name1,attr_value1,attr_name2,attr_value2) # get elements using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attr_name1,attr_value1,attr_name2,attr_value2) # get elements using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Array<Meteor::Element>] element array (要素配列) # def elements(*args) @parser.elements(*args) end # # get (child) elements using selector like css3(CSS3のようにセレクタを用いて(子)要素を取得する) # CSS3 selector partial support (CSS3セレクタの部分的サポート) # @param selector [String] selector (セレクタ) # @return [Array<Meteor::Element>] element (要素) # def find(selector) @parser.find(selector) end alias :css :find # # get cx(comment extension) tag (CX(コメント拡張)タグを取得する) # @overload cxtag(tag,id) # get cx(comment extension) tag using tag name and id attribute (タグ名とID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String] id id attribute value (ID属性値) # @return [Meteor::Element] element(要素) # @overload cxtag(id) # get cx(comment extension) tag using id attribute (ID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String] id id attribute value (ID属性値) # @return [Meteor::Element] element (要素) # def cxtag(*args) @parser.cxtag(*args) end # # @overload attr(attr) # set attribute of element (要素の属性をセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attr attribute (属性) # @return [Meteor::Element] element (要素) # @deprecated # @overload attr(attr_name,attr_value) # set attribute of element (要素の属性をセットする) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String,true,false] attr_value attribute value (属性値) # @return [Meteor::Element] element (要素) # @overload attr(attr_name) # get attribute value of element (要素の属性値を取得する) # @param [String,Symbol] attr_name attribute name (属性名) # @return [String] attribute value (属性値) # def attr(attrs,*args) @parser.attr(self, attrs,*args) end # # set attribute of element (要素の属性をセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attr attribute (属性) # @return [Meteor::Element] element (要素) # def attr=(attr) @parser.attr(self,attr) end # # set attribute map (要素マップをセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element (要素) def attrs=(attrs) @parser.attrs(self,attrs) end # # get attribute map (属性マップを取得する) # @return [Hash<String,String>,Hash<Symbol,String>] attribute map (属性マップ) # def attrs @parser.attrs(self) end # # @overload attr_map(attr_map) # set attribute map (属性マップをセットする) # @param [Meteor::AttributeMap] attr_map attribute map (属性マップ) # @return [Meteor::Element] element (要素) # @deprecated # @overload attr_map() # get attribute map (属性マップを取得する) # @return [Meteor::AttributeMap] attribute map (属性マップ) # def attr_map(*args) @parser.attr_map(self, *args) end # # set attribute map (属性マップをセットする) # @param [Meteor::AttributeMap] attr_map attribute map (属性マップ) # @return [Meteor::Element] element (要素) # def attr_map=(attr_map) @parser.attr_map(self,attr_map) end # # @overload content(content,entity_ref=true) # set content of element (要素の内容をセットする) # @param [String] content content of element (要素の内容) # @param [true,false] entity_ref entity reference flag (エンティティ参照フラグ) # @return [Meteor::Element] element (要素) # @deprecated # @overload content(content) # set content of element (要素の内容をセットする) # @param [String] content content of element (要素の内容) # @return [Meteor::Element] element (要素) # @deprecated # @overload content() # get content of element (要素の内容を取得する) # @return [String] content (内容) # def content(*args) @parser.content(self, *args) end # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def content=(value) @parser.content(self, value) end # # set attribute (属性をセットする) # @param [String,Symbol] name attribute name (属性の名前) # @param [String] value attribute value (属性の値) # @return [Meteor::Element] element (要素) # def []=(name, value) @parser.attr(self, name, value) end # # get attribute value (属性の値を取得する) # @param [String,Symbol] name attribute name (属性の名前) # @return [String] attribute value (属性の値) # def [](name) @parser.attr(self, name) end # # remove attribute of element (要素の属性を消す) # @param [String,Symbol] attr_name attribute name (属性名) # @return [Meteor::Element] element (要素) # def remove_attr(attr_name) @parser.remove_attr(self, attr_name) end # # remove element (要素を削除する) # def remove @parser.remove_element(self) end # # reflect (反映する) # def flush @parser.flush end # # @overload execute(hook) # run action of Hooker (Hookerクラスの処理を実行する) # @param [Meteor::Hook::Hooker] hook Hooker object (Hookerオブジェクト) # @overload execute(loop,list) # run action of Looper (Looperクラスの処理を実行する) # @param [Meteor::Hook::Looper] loop Looper object (Looperオブジェクト) # @param [Array] list 配列 # def execute(*args) @parser.execute(self, *args) end end |
#raw_content ⇒ false, true
Returns entity ref flag of content (内容のエンティティ参照フラグ).
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
# File 'lib/meteor.rb', line 79 class Element attr_accessor :tag attr_accessor :attributes attr_accessor :mixed_content attr_accessor :raw_content attr_accessor :pattern attr_accessor :document_sync attr_accessor :empty attr_accessor :cx attr_accessor :mono attr_accessor :parser attr_accessor :type_value attr_accessor :usable attr_accessor :origin attr_accessor :copy attr_accessor :removed alias :name :tag alias :name= :tag= # # initializer (イニシャライザ) # @overload initialize(tag) # @param [String,Symbol] tag tag name (タグ名) # @overload initialize(elm) # @param [Meteor::Element] elm element (要素) # @overload initialize(elm,ps) # @param [Meteor::Element] elm element (要素) # @param [Meteor::Parser] ps parser (パーサ) # def initialize(*args) case args.length when ONE if args[0].kind_of?(String) initialize_s(args[0]) elsif args[0].kind_of?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when TWO @tag = args[0].tag @attributes = String.new(args[0].attributes) @mixed_content = String.new(args[0].mixed_content) #@pattern = String.new(args[0].pattern) @pattern = args[0].pattern @document = String.new(args[0].document) @empty = args[0].empty @cx = args[0].cx @mono = args[0].mono @parser = args[1] #@usable = false @origin = args[0] args[0].copy = self when ZERO else raise ArgumentError end end # # initializer (イニシャライザ) # @param [String] tag tag name (タグ名) # def initialize_s(tag) @tag = tag #@attributes = nil #@mixed_content = nil #@pattern = nil #@document = nil #@parser=nil #@empty = false #@cx = false #@mono = false #@parent = false @usable = true end private :initialize_s # # initializer (イニシャライザ) # @param [Meteor::Element] elm element (要素) # def initialize_e(elm) @tag = elm.tag @attributes = String.new(elm.attributes) #@pattern = String.new(elm.pattern) @pattern = elm.pattern @document = String.new(elm.document) @empty = elm.empty @cx = elm.cx @mono = elm.mono @origin = elm @parser = elm.parser @usable = true end private :initialize_e # # make copy (コピーを作成する) # @overload new!(elm,ps) # @param [Meteor::Element] elm element (要素) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def self.new!(*args) case args.length when TWO @obj = args[1].element_hook if @obj @obj.attributes = String.new(args[0].attributes) @obj.mixed_content = String.new(args[0].mixed_content) #@obj.pattern = String.new(args[0].pattern) @obj.document = String.new(args[0].document) @obj else @obj = self.new(args[0], args[1]) args[1].element_hook = @obj @obj end else raise ArgumentError end end # # clone (複製する) # @return [Meteor::Element] element (要素) # def clone obj = self.parser.element_cache[self.object_id] if obj obj.attributes = String.new(self.attributes) obj.mixed_content = String.new(self.mixed_content) #obj.pattern = String.new(self.pattern) obj.document = String.new(self.document) obj.usable = true obj else obj = self.new(self) self.parser.element_cache[self.object_id] = obj obj end end # # set document (ドキュメントをセットする) # @param [String] doc document (ドキュメント) # def document=(doc) @document_sync = false @document = doc end # # get document (ドキュメントを取得する) # @return [String] document (ドキュメント) # def document if @document_sync @document_sync = false case @parser.doc_type when Parser::HTML, Parser::HTML5 if @cx #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4 @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->" else if @empty #@pattern_cc = '' << TAG_OPEN << elm.tag << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.tag << TAG_CLOSE @document = "<#{@tag}#{@attributes}>#{@mixed_content}</#{@tag}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @tag << @attributes << Meteor::Core::Kernel::TAG_CLOSE #@document = "<#{@name}#{@attributes}>" end end when Parser::XHTML, Parser::XHTML5, Parser::XML if @cx #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4 @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->" else if @empty #@pattern_cc = '' << TAG_OPEN << elm.tag << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.tag << TAG_CLOSE @document = "<#{@tag}#{@attributes}>#{@mixed_content}</#{@tag}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @tag << @attributes << Meteor::Core::Kernel::TAG_CLOSE3 #@document = "<#{@name}#{@attributes}/>" end end end else @document end end # # get element (要素を取得する) # @overload element() # get element (要素を取得する) # @return [Meteor::Element] element (要素) # @overload element(tag) # get element using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @return [Meteor::Element] element (要素) # @overload element(tag,attrs) # get element using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element (要素) # @overload element(attrs) # get element using attribute map (属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element(要素) # @overload element(tag,attr_name,attr_value) # get element using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Meteor::Element] element (要素) # @overload element(attr_name,attr_value) # get element using attribute(name="value") (属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name 属性名 # @param [String] attr_value 属性値 # @return [Meteor::Element] element (要素) # @overload element(tag,attr_name1,attr_value1,attr_name2,attr_value2) # get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Meteor::Element] element (要素) # @overload element(attr_name1,attr_value1,attr_name2,attr_value2) # get element using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name1 属性名1 # @param [String] attr_value1 属性値1 # @param [String,Symbol] attr_name2 属性名2 # @param [String] attr_value2 属性値2 # @return [Meteor::Element] element(要素) # @overload element(elm) # mirror element (要素を射影する) # @param [Meteor::Element] elm element(要素) # @return [Meteor::Element] element(要素) # def element(elm = nil, attrs = nil,*args) #case args.length #when ZERO if !elm && !attrs @parser.element(self) else @parser.element(elm, attrs,*args) end end alias :child :element # # get elements (要素を取得する) # @overload elements(tag) # get elements using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @return [Array<Meteor::Element>] element array(要素配列) # @overload elements(tag,attrs) # get elements using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attrs) # get elements using attribute map (属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(tag,attr_name,attr_value) # get elements using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attr_name,attr_value) # get elements using attribute(name="value") (属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(tag,attr_name1,attr_value1,attr_name2,attr_value2) # get elements using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attr_name1,attr_value1,attr_name2,attr_value2) # get elements using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Array<Meteor::Element>] element array (要素配列) # def elements(*args) @parser.elements(*args) end # # get (child) elements using selector like css3(CSS3のようにセレクタを用いて(子)要素を取得する) # CSS3 selector partial support (CSS3セレクタの部分的サポート) # @param selector [String] selector (セレクタ) # @return [Array<Meteor::Element>] element (要素) # def find(selector) @parser.find(selector) end alias :css :find # # get cx(comment extension) tag (CX(コメント拡張)タグを取得する) # @overload cxtag(tag,id) # get cx(comment extension) tag using tag name and id attribute (タグ名とID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String] id id attribute value (ID属性値) # @return [Meteor::Element] element(要素) # @overload cxtag(id) # get cx(comment extension) tag using id attribute (ID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String] id id attribute value (ID属性値) # @return [Meteor::Element] element (要素) # def cxtag(*args) @parser.cxtag(*args) end # # @overload attr(attr) # set attribute of element (要素の属性をセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attr attribute (属性) # @return [Meteor::Element] element (要素) # @deprecated # @overload attr(attr_name,attr_value) # set attribute of element (要素の属性をセットする) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String,true,false] attr_value attribute value (属性値) # @return [Meteor::Element] element (要素) # @overload attr(attr_name) # get attribute value of element (要素の属性値を取得する) # @param [String,Symbol] attr_name attribute name (属性名) # @return [String] attribute value (属性値) # def attr(attrs,*args) @parser.attr(self, attrs,*args) end # # set attribute of element (要素の属性をセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attr attribute (属性) # @return [Meteor::Element] element (要素) # def attr=(attr) @parser.attr(self,attr) end # # set attribute map (要素マップをセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element (要素) def attrs=(attrs) @parser.attrs(self,attrs) end # # get attribute map (属性マップを取得する) # @return [Hash<String,String>,Hash<Symbol,String>] attribute map (属性マップ) # def attrs @parser.attrs(self) end # # @overload attr_map(attr_map) # set attribute map (属性マップをセットする) # @param [Meteor::AttributeMap] attr_map attribute map (属性マップ) # @return [Meteor::Element] element (要素) # @deprecated # @overload attr_map() # get attribute map (属性マップを取得する) # @return [Meteor::AttributeMap] attribute map (属性マップ) # def attr_map(*args) @parser.attr_map(self, *args) end # # set attribute map (属性マップをセットする) # @param [Meteor::AttributeMap] attr_map attribute map (属性マップ) # @return [Meteor::Element] element (要素) # def attr_map=(attr_map) @parser.attr_map(self,attr_map) end # # @overload content(content,entity_ref=true) # set content of element (要素の内容をセットする) # @param [String] content content of element (要素の内容) # @param [true,false] entity_ref entity reference flag (エンティティ参照フラグ) # @return [Meteor::Element] element (要素) # @deprecated # @overload content(content) # set content of element (要素の内容をセットする) # @param [String] content content of element (要素の内容) # @return [Meteor::Element] element (要素) # @deprecated # @overload content() # get content of element (要素の内容を取得する) # @return [String] content (内容) # def content(*args) @parser.content(self, *args) end # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def content=(value) @parser.content(self, value) end # # set attribute (属性をセットする) # @param [String,Symbol] name attribute name (属性の名前) # @param [String] value attribute value (属性の値) # @return [Meteor::Element] element (要素) # def []=(name, value) @parser.attr(self, name, value) end # # get attribute value (属性の値を取得する) # @param [String,Symbol] name attribute name (属性の名前) # @return [String] attribute value (属性の値) # def [](name) @parser.attr(self, name) end # # remove attribute of element (要素の属性を消す) # @param [String,Symbol] attr_name attribute name (属性名) # @return [Meteor::Element] element (要素) # def remove_attr(attr_name) @parser.remove_attr(self, attr_name) end # # remove element (要素を削除する) # def remove @parser.remove_element(self) end # # reflect (反映する) # def flush @parser.flush end # # @overload execute(hook) # run action of Hooker (Hookerクラスの処理を実行する) # @param [Meteor::Hook::Hooker] hook Hooker object (Hookerオブジェクト) # @overload execute(loop,list) # run action of Looper (Looperクラスの処理を実行する) # @param [Meteor::Hook::Looper] loop Looper object (Looperオブジェクト) # @param [Array] list 配列 # def execute(*args) @parser.execute(self, *args) end end |
#removed ⇒ true, false
Returns delete flag (削除フラグ).
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
# File 'lib/meteor.rb', line 79 class Element attr_accessor :tag attr_accessor :attributes attr_accessor :mixed_content attr_accessor :raw_content attr_accessor :pattern attr_accessor :document_sync attr_accessor :empty attr_accessor :cx attr_accessor :mono attr_accessor :parser attr_accessor :type_value attr_accessor :usable attr_accessor :origin attr_accessor :copy attr_accessor :removed alias :name :tag alias :name= :tag= # # initializer (イニシャライザ) # @overload initialize(tag) # @param [String,Symbol] tag tag name (タグ名) # @overload initialize(elm) # @param [Meteor::Element] elm element (要素) # @overload initialize(elm,ps) # @param [Meteor::Element] elm element (要素) # @param [Meteor::Parser] ps parser (パーサ) # def initialize(*args) case args.length when ONE if args[0].kind_of?(String) initialize_s(args[0]) elsif args[0].kind_of?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when TWO @tag = args[0].tag @attributes = String.new(args[0].attributes) @mixed_content = String.new(args[0].mixed_content) #@pattern = String.new(args[0].pattern) @pattern = args[0].pattern @document = String.new(args[0].document) @empty = args[0].empty @cx = args[0].cx @mono = args[0].mono @parser = args[1] #@usable = false @origin = args[0] args[0].copy = self when ZERO else raise ArgumentError end end # # initializer (イニシャライザ) # @param [String] tag tag name (タグ名) # def initialize_s(tag) @tag = tag #@attributes = nil #@mixed_content = nil #@pattern = nil #@document = nil #@parser=nil #@empty = false #@cx = false #@mono = false #@parent = false @usable = true end private :initialize_s # # initializer (イニシャライザ) # @param [Meteor::Element] elm element (要素) # def initialize_e(elm) @tag = elm.tag @attributes = String.new(elm.attributes) #@pattern = String.new(elm.pattern) @pattern = elm.pattern @document = String.new(elm.document) @empty = elm.empty @cx = elm.cx @mono = elm.mono @origin = elm @parser = elm.parser @usable = true end private :initialize_e # # make copy (コピーを作成する) # @overload new!(elm,ps) # @param [Meteor::Element] elm element (要素) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def self.new!(*args) case args.length when TWO @obj = args[1].element_hook if @obj @obj.attributes = String.new(args[0].attributes) @obj.mixed_content = String.new(args[0].mixed_content) #@obj.pattern = String.new(args[0].pattern) @obj.document = String.new(args[0].document) @obj else @obj = self.new(args[0], args[1]) args[1].element_hook = @obj @obj end else raise ArgumentError end end # # clone (複製する) # @return [Meteor::Element] element (要素) # def clone obj = self.parser.element_cache[self.object_id] if obj obj.attributes = String.new(self.attributes) obj.mixed_content = String.new(self.mixed_content) #obj.pattern = String.new(self.pattern) obj.document = String.new(self.document) obj.usable = true obj else obj = self.new(self) self.parser.element_cache[self.object_id] = obj obj end end # # set document (ドキュメントをセットする) # @param [String] doc document (ドキュメント) # def document=(doc) @document_sync = false @document = doc end # # get document (ドキュメントを取得する) # @return [String] document (ドキュメント) # def document if @document_sync @document_sync = false case @parser.doc_type when Parser::HTML, Parser::HTML5 if @cx #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4 @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->" else if @empty #@pattern_cc = '' << TAG_OPEN << elm.tag << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.tag << TAG_CLOSE @document = "<#{@tag}#{@attributes}>#{@mixed_content}</#{@tag}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @tag << @attributes << Meteor::Core::Kernel::TAG_CLOSE #@document = "<#{@name}#{@attributes}>" end end when Parser::XHTML, Parser::XHTML5, Parser::XML if @cx #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4 @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->" else if @empty #@pattern_cc = '' << TAG_OPEN << elm.tag << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.tag << TAG_CLOSE @document = "<#{@tag}#{@attributes}>#{@mixed_content}</#{@tag}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @tag << @attributes << Meteor::Core::Kernel::TAG_CLOSE3 #@document = "<#{@name}#{@attributes}/>" end end end else @document end end # # get element (要素を取得する) # @overload element() # get element (要素を取得する) # @return [Meteor::Element] element (要素) # @overload element(tag) # get element using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @return [Meteor::Element] element (要素) # @overload element(tag,attrs) # get element using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element (要素) # @overload element(attrs) # get element using attribute map (属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element(要素) # @overload element(tag,attr_name,attr_value) # get element using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Meteor::Element] element (要素) # @overload element(attr_name,attr_value) # get element using attribute(name="value") (属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name 属性名 # @param [String] attr_value 属性値 # @return [Meteor::Element] element (要素) # @overload element(tag,attr_name1,attr_value1,attr_name2,attr_value2) # get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Meteor::Element] element (要素) # @overload element(attr_name1,attr_value1,attr_name2,attr_value2) # get element using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name1 属性名1 # @param [String] attr_value1 属性値1 # @param [String,Symbol] attr_name2 属性名2 # @param [String] attr_value2 属性値2 # @return [Meteor::Element] element(要素) # @overload element(elm) # mirror element (要素を射影する) # @param [Meteor::Element] elm element(要素) # @return [Meteor::Element] element(要素) # def element(elm = nil, attrs = nil,*args) #case args.length #when ZERO if !elm && !attrs @parser.element(self) else @parser.element(elm, attrs,*args) end end alias :child :element # # get elements (要素を取得する) # @overload elements(tag) # get elements using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @return [Array<Meteor::Element>] element array(要素配列) # @overload elements(tag,attrs) # get elements using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attrs) # get elements using attribute map (属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(tag,attr_name,attr_value) # get elements using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attr_name,attr_value) # get elements using attribute(name="value") (属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(tag,attr_name1,attr_value1,attr_name2,attr_value2) # get elements using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attr_name1,attr_value1,attr_name2,attr_value2) # get elements using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Array<Meteor::Element>] element array (要素配列) # def elements(*args) @parser.elements(*args) end # # get (child) elements using selector like css3(CSS3のようにセレクタを用いて(子)要素を取得する) # CSS3 selector partial support (CSS3セレクタの部分的サポート) # @param selector [String] selector (セレクタ) # @return [Array<Meteor::Element>] element (要素) # def find(selector) @parser.find(selector) end alias :css :find # # get cx(comment extension) tag (CX(コメント拡張)タグを取得する) # @overload cxtag(tag,id) # get cx(comment extension) tag using tag name and id attribute (タグ名とID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String] id id attribute value (ID属性値) # @return [Meteor::Element] element(要素) # @overload cxtag(id) # get cx(comment extension) tag using id attribute (ID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String] id id attribute value (ID属性値) # @return [Meteor::Element] element (要素) # def cxtag(*args) @parser.cxtag(*args) end # # @overload attr(attr) # set attribute of element (要素の属性をセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attr attribute (属性) # @return [Meteor::Element] element (要素) # @deprecated # @overload attr(attr_name,attr_value) # set attribute of element (要素の属性をセットする) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String,true,false] attr_value attribute value (属性値) # @return [Meteor::Element] element (要素) # @overload attr(attr_name) # get attribute value of element (要素の属性値を取得する) # @param [String,Symbol] attr_name attribute name (属性名) # @return [String] attribute value (属性値) # def attr(attrs,*args) @parser.attr(self, attrs,*args) end # # set attribute of element (要素の属性をセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attr attribute (属性) # @return [Meteor::Element] element (要素) # def attr=(attr) @parser.attr(self,attr) end # # set attribute map (要素マップをセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element (要素) def attrs=(attrs) @parser.attrs(self,attrs) end # # get attribute map (属性マップを取得する) # @return [Hash<String,String>,Hash<Symbol,String>] attribute map (属性マップ) # def attrs @parser.attrs(self) end # # @overload attr_map(attr_map) # set attribute map (属性マップをセットする) # @param [Meteor::AttributeMap] attr_map attribute map (属性マップ) # @return [Meteor::Element] element (要素) # @deprecated # @overload attr_map() # get attribute map (属性マップを取得する) # @return [Meteor::AttributeMap] attribute map (属性マップ) # def attr_map(*args) @parser.attr_map(self, *args) end # # set attribute map (属性マップをセットする) # @param [Meteor::AttributeMap] attr_map attribute map (属性マップ) # @return [Meteor::Element] element (要素) # def attr_map=(attr_map) @parser.attr_map(self,attr_map) end # # @overload content(content,entity_ref=true) # set content of element (要素の内容をセットする) # @param [String] content content of element (要素の内容) # @param [true,false] entity_ref entity reference flag (エンティティ参照フラグ) # @return [Meteor::Element] element (要素) # @deprecated # @overload content(content) # set content of element (要素の内容をセットする) # @param [String] content content of element (要素の内容) # @return [Meteor::Element] element (要素) # @deprecated # @overload content() # get content of element (要素の内容を取得する) # @return [String] content (内容) # def content(*args) @parser.content(self, *args) end # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def content=(value) @parser.content(self, value) end # # set attribute (属性をセットする) # @param [String,Symbol] name attribute name (属性の名前) # @param [String] value attribute value (属性の値) # @return [Meteor::Element] element (要素) # def []=(name, value) @parser.attr(self, name, value) end # # get attribute value (属性の値を取得する) # @param [String,Symbol] name attribute name (属性の名前) # @return [String] attribute value (属性の値) # def [](name) @parser.attr(self, name) end # # remove attribute of element (要素の属性を消す) # @param [String,Symbol] attr_name attribute name (属性名) # @return [Meteor::Element] element (要素) # def remove_attr(attr_name) @parser.remove_attr(self, attr_name) end # # remove element (要素を削除する) # def remove @parser.remove_element(self) end # # reflect (反映する) # def flush @parser.flush end # # @overload execute(hook) # run action of Hooker (Hookerクラスの処理を実行する) # @param [Meteor::Hook::Hooker] hook Hooker object (Hookerオブジェクト) # @overload execute(loop,list) # run action of Looper (Looperクラスの処理を実行する) # @param [Meteor::Hook::Looper] loop Looper object (Looperオブジェクト) # @param [Array] list 配列 # def execute(*args) @parser.execute(self, *args) end end |
#tag ⇒ Object Also known as: name
Returns the value of attribute tag.
81 82 83 |
# File 'lib/meteor.rb', line 81 def tag @tag end |
#type_value ⇒ String
Returns type (タイプ属性).
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
# File 'lib/meteor.rb', line 79 class Element attr_accessor :tag attr_accessor :attributes attr_accessor :mixed_content attr_accessor :raw_content attr_accessor :pattern attr_accessor :document_sync attr_accessor :empty attr_accessor :cx attr_accessor :mono attr_accessor :parser attr_accessor :type_value attr_accessor :usable attr_accessor :origin attr_accessor :copy attr_accessor :removed alias :name :tag alias :name= :tag= # # initializer (イニシャライザ) # @overload initialize(tag) # @param [String,Symbol] tag tag name (タグ名) # @overload initialize(elm) # @param [Meteor::Element] elm element (要素) # @overload initialize(elm,ps) # @param [Meteor::Element] elm element (要素) # @param [Meteor::Parser] ps parser (パーサ) # def initialize(*args) case args.length when ONE if args[0].kind_of?(String) initialize_s(args[0]) elsif args[0].kind_of?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when TWO @tag = args[0].tag @attributes = String.new(args[0].attributes) @mixed_content = String.new(args[0].mixed_content) #@pattern = String.new(args[0].pattern) @pattern = args[0].pattern @document = String.new(args[0].document) @empty = args[0].empty @cx = args[0].cx @mono = args[0].mono @parser = args[1] #@usable = false @origin = args[0] args[0].copy = self when ZERO else raise ArgumentError end end # # initializer (イニシャライザ) # @param [String] tag tag name (タグ名) # def initialize_s(tag) @tag = tag #@attributes = nil #@mixed_content = nil #@pattern = nil #@document = nil #@parser=nil #@empty = false #@cx = false #@mono = false #@parent = false @usable = true end private :initialize_s # # initializer (イニシャライザ) # @param [Meteor::Element] elm element (要素) # def initialize_e(elm) @tag = elm.tag @attributes = String.new(elm.attributes) #@pattern = String.new(elm.pattern) @pattern = elm.pattern @document = String.new(elm.document) @empty = elm.empty @cx = elm.cx @mono = elm.mono @origin = elm @parser = elm.parser @usable = true end private :initialize_e # # make copy (コピーを作成する) # @overload new!(elm,ps) # @param [Meteor::Element] elm element (要素) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def self.new!(*args) case args.length when TWO @obj = args[1].element_hook if @obj @obj.attributes = String.new(args[0].attributes) @obj.mixed_content = String.new(args[0].mixed_content) #@obj.pattern = String.new(args[0].pattern) @obj.document = String.new(args[0].document) @obj else @obj = self.new(args[0], args[1]) args[1].element_hook = @obj @obj end else raise ArgumentError end end # # clone (複製する) # @return [Meteor::Element] element (要素) # def clone obj = self.parser.element_cache[self.object_id] if obj obj.attributes = String.new(self.attributes) obj.mixed_content = String.new(self.mixed_content) #obj.pattern = String.new(self.pattern) obj.document = String.new(self.document) obj.usable = true obj else obj = self.new(self) self.parser.element_cache[self.object_id] = obj obj end end # # set document (ドキュメントをセットする) # @param [String] doc document (ドキュメント) # def document=(doc) @document_sync = false @document = doc end # # get document (ドキュメントを取得する) # @return [String] document (ドキュメント) # def document if @document_sync @document_sync = false case @parser.doc_type when Parser::HTML, Parser::HTML5 if @cx #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4 @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->" else if @empty #@pattern_cc = '' << TAG_OPEN << elm.tag << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.tag << TAG_CLOSE @document = "<#{@tag}#{@attributes}>#{@mixed_content}</#{@tag}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @tag << @attributes << Meteor::Core::Kernel::TAG_CLOSE #@document = "<#{@name}#{@attributes}>" end end when Parser::XHTML, Parser::XHTML5, Parser::XML if @cx #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4 @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->" else if @empty #@pattern_cc = '' << TAG_OPEN << elm.tag << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.tag << TAG_CLOSE @document = "<#{@tag}#{@attributes}>#{@mixed_content}</#{@tag}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @tag << @attributes << Meteor::Core::Kernel::TAG_CLOSE3 #@document = "<#{@name}#{@attributes}/>" end end end else @document end end # # get element (要素を取得する) # @overload element() # get element (要素を取得する) # @return [Meteor::Element] element (要素) # @overload element(tag) # get element using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @return [Meteor::Element] element (要素) # @overload element(tag,attrs) # get element using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element (要素) # @overload element(attrs) # get element using attribute map (属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element(要素) # @overload element(tag,attr_name,attr_value) # get element using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Meteor::Element] element (要素) # @overload element(attr_name,attr_value) # get element using attribute(name="value") (属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name 属性名 # @param [String] attr_value 属性値 # @return [Meteor::Element] element (要素) # @overload element(tag,attr_name1,attr_value1,attr_name2,attr_value2) # get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Meteor::Element] element (要素) # @overload element(attr_name1,attr_value1,attr_name2,attr_value2) # get element using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name1 属性名1 # @param [String] attr_value1 属性値1 # @param [String,Symbol] attr_name2 属性名2 # @param [String] attr_value2 属性値2 # @return [Meteor::Element] element(要素) # @overload element(elm) # mirror element (要素を射影する) # @param [Meteor::Element] elm element(要素) # @return [Meteor::Element] element(要素) # def element(elm = nil, attrs = nil,*args) #case args.length #when ZERO if !elm && !attrs @parser.element(self) else @parser.element(elm, attrs,*args) end end alias :child :element # # get elements (要素を取得する) # @overload elements(tag) # get elements using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @return [Array<Meteor::Element>] element array(要素配列) # @overload elements(tag,attrs) # get elements using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attrs) # get elements using attribute map (属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(tag,attr_name,attr_value) # get elements using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attr_name,attr_value) # get elements using attribute(name="value") (属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(tag,attr_name1,attr_value1,attr_name2,attr_value2) # get elements using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attr_name1,attr_value1,attr_name2,attr_value2) # get elements using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Array<Meteor::Element>] element array (要素配列) # def elements(*args) @parser.elements(*args) end # # get (child) elements using selector like css3(CSS3のようにセレクタを用いて(子)要素を取得する) # CSS3 selector partial support (CSS3セレクタの部分的サポート) # @param selector [String] selector (セレクタ) # @return [Array<Meteor::Element>] element (要素) # def find(selector) @parser.find(selector) end alias :css :find # # get cx(comment extension) tag (CX(コメント拡張)タグを取得する) # @overload cxtag(tag,id) # get cx(comment extension) tag using tag name and id attribute (タグ名とID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String] id id attribute value (ID属性値) # @return [Meteor::Element] element(要素) # @overload cxtag(id) # get cx(comment extension) tag using id attribute (ID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String] id id attribute value (ID属性値) # @return [Meteor::Element] element (要素) # def cxtag(*args) @parser.cxtag(*args) end # # @overload attr(attr) # set attribute of element (要素の属性をセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attr attribute (属性) # @return [Meteor::Element] element (要素) # @deprecated # @overload attr(attr_name,attr_value) # set attribute of element (要素の属性をセットする) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String,true,false] attr_value attribute value (属性値) # @return [Meteor::Element] element (要素) # @overload attr(attr_name) # get attribute value of element (要素の属性値を取得する) # @param [String,Symbol] attr_name attribute name (属性名) # @return [String] attribute value (属性値) # def attr(attrs,*args) @parser.attr(self, attrs,*args) end # # set attribute of element (要素の属性をセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attr attribute (属性) # @return [Meteor::Element] element (要素) # def attr=(attr) @parser.attr(self,attr) end # # set attribute map (要素マップをセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element (要素) def attrs=(attrs) @parser.attrs(self,attrs) end # # get attribute map (属性マップを取得する) # @return [Hash<String,String>,Hash<Symbol,String>] attribute map (属性マップ) # def attrs @parser.attrs(self) end # # @overload attr_map(attr_map) # set attribute map (属性マップをセットする) # @param [Meteor::AttributeMap] attr_map attribute map (属性マップ) # @return [Meteor::Element] element (要素) # @deprecated # @overload attr_map() # get attribute map (属性マップを取得する) # @return [Meteor::AttributeMap] attribute map (属性マップ) # def attr_map(*args) @parser.attr_map(self, *args) end # # set attribute map (属性マップをセットする) # @param [Meteor::AttributeMap] attr_map attribute map (属性マップ) # @return [Meteor::Element] element (要素) # def attr_map=(attr_map) @parser.attr_map(self,attr_map) end # # @overload content(content,entity_ref=true) # set content of element (要素の内容をセットする) # @param [String] content content of element (要素の内容) # @param [true,false] entity_ref entity reference flag (エンティティ参照フラグ) # @return [Meteor::Element] element (要素) # @deprecated # @overload content(content) # set content of element (要素の内容をセットする) # @param [String] content content of element (要素の内容) # @return [Meteor::Element] element (要素) # @deprecated # @overload content() # get content of element (要素の内容を取得する) # @return [String] content (内容) # def content(*args) @parser.content(self, *args) end # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def content=(value) @parser.content(self, value) end # # set attribute (属性をセットする) # @param [String,Symbol] name attribute name (属性の名前) # @param [String] value attribute value (属性の値) # @return [Meteor::Element] element (要素) # def []=(name, value) @parser.attr(self, name, value) end # # get attribute value (属性の値を取得する) # @param [String,Symbol] name attribute name (属性の名前) # @return [String] attribute value (属性の値) # def [](name) @parser.attr(self, name) end # # remove attribute of element (要素の属性を消す) # @param [String,Symbol] attr_name attribute name (属性名) # @return [Meteor::Element] element (要素) # def remove_attr(attr_name) @parser.remove_attr(self, attr_name) end # # remove element (要素を削除する) # def remove @parser.remove_element(self) end # # reflect (反映する) # def flush @parser.flush end # # @overload execute(hook) # run action of Hooker (Hookerクラスの処理を実行する) # @param [Meteor::Hook::Hooker] hook Hooker object (Hookerオブジェクト) # @overload execute(loop,list) # run action of Looper (Looperクラスの処理を実行する) # @param [Meteor::Hook::Looper] loop Looper object (Looperオブジェクト) # @param [Array] list 配列 # def execute(*args) @parser.execute(self, *args) end end |
#usable ⇒ true, false
Returns usable flag (有効・無効フラグ).
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
# File 'lib/meteor.rb', line 79 class Element attr_accessor :tag attr_accessor :attributes attr_accessor :mixed_content attr_accessor :raw_content attr_accessor :pattern attr_accessor :document_sync attr_accessor :empty attr_accessor :cx attr_accessor :mono attr_accessor :parser attr_accessor :type_value attr_accessor :usable attr_accessor :origin attr_accessor :copy attr_accessor :removed alias :name :tag alias :name= :tag= # # initializer (イニシャライザ) # @overload initialize(tag) # @param [String,Symbol] tag tag name (タグ名) # @overload initialize(elm) # @param [Meteor::Element] elm element (要素) # @overload initialize(elm,ps) # @param [Meteor::Element] elm element (要素) # @param [Meteor::Parser] ps parser (パーサ) # def initialize(*args) case args.length when ONE if args[0].kind_of?(String) initialize_s(args[0]) elsif args[0].kind_of?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when TWO @tag = args[0].tag @attributes = String.new(args[0].attributes) @mixed_content = String.new(args[0].mixed_content) #@pattern = String.new(args[0].pattern) @pattern = args[0].pattern @document = String.new(args[0].document) @empty = args[0].empty @cx = args[0].cx @mono = args[0].mono @parser = args[1] #@usable = false @origin = args[0] args[0].copy = self when ZERO else raise ArgumentError end end # # initializer (イニシャライザ) # @param [String] tag tag name (タグ名) # def initialize_s(tag) @tag = tag #@attributes = nil #@mixed_content = nil #@pattern = nil #@document = nil #@parser=nil #@empty = false #@cx = false #@mono = false #@parent = false @usable = true end private :initialize_s # # initializer (イニシャライザ) # @param [Meteor::Element] elm element (要素) # def initialize_e(elm) @tag = elm.tag @attributes = String.new(elm.attributes) #@pattern = String.new(elm.pattern) @pattern = elm.pattern @document = String.new(elm.document) @empty = elm.empty @cx = elm.cx @mono = elm.mono @origin = elm @parser = elm.parser @usable = true end private :initialize_e # # make copy (コピーを作成する) # @overload new!(elm,ps) # @param [Meteor::Element] elm element (要素) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def self.new!(*args) case args.length when TWO @obj = args[1].element_hook if @obj @obj.attributes = String.new(args[0].attributes) @obj.mixed_content = String.new(args[0].mixed_content) #@obj.pattern = String.new(args[0].pattern) @obj.document = String.new(args[0].document) @obj else @obj = self.new(args[0], args[1]) args[1].element_hook = @obj @obj end else raise ArgumentError end end # # clone (複製する) # @return [Meteor::Element] element (要素) # def clone obj = self.parser.element_cache[self.object_id] if obj obj.attributes = String.new(self.attributes) obj.mixed_content = String.new(self.mixed_content) #obj.pattern = String.new(self.pattern) obj.document = String.new(self.document) obj.usable = true obj else obj = self.new(self) self.parser.element_cache[self.object_id] = obj obj end end # # set document (ドキュメントをセットする) # @param [String] doc document (ドキュメント) # def document=(doc) @document_sync = false @document = doc end # # get document (ドキュメントを取得する) # @return [String] document (ドキュメント) # def document if @document_sync @document_sync = false case @parser.doc_type when Parser::HTML, Parser::HTML5 if @cx #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4 @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->" else if @empty #@pattern_cc = '' << TAG_OPEN << elm.tag << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.tag << TAG_CLOSE @document = "<#{@tag}#{@attributes}>#{@mixed_content}</#{@tag}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @tag << @attributes << Meteor::Core::Kernel::TAG_CLOSE #@document = "<#{@name}#{@attributes}>" end end when Parser::XHTML, Parser::XHTML5, Parser::XML if @cx #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4 @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->" else if @empty #@pattern_cc = '' << TAG_OPEN << elm.tag << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.tag << TAG_CLOSE @document = "<#{@tag}#{@attributes}>#{@mixed_content}</#{@tag}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @tag << @attributes << Meteor::Core::Kernel::TAG_CLOSE3 #@document = "<#{@name}#{@attributes}/>" end end end else @document end end # # get element (要素を取得する) # @overload element() # get element (要素を取得する) # @return [Meteor::Element] element (要素) # @overload element(tag) # get element using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @return [Meteor::Element] element (要素) # @overload element(tag,attrs) # get element using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element (要素) # @overload element(attrs) # get element using attribute map (属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element(要素) # @overload element(tag,attr_name,attr_value) # get element using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Meteor::Element] element (要素) # @overload element(attr_name,attr_value) # get element using attribute(name="value") (属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name 属性名 # @param [String] attr_value 属性値 # @return [Meteor::Element] element (要素) # @overload element(tag,attr_name1,attr_value1,attr_name2,attr_value2) # get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Meteor::Element] element (要素) # @overload element(attr_name1,attr_value1,attr_name2,attr_value2) # get element using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name1 属性名1 # @param [String] attr_value1 属性値1 # @param [String,Symbol] attr_name2 属性名2 # @param [String] attr_value2 属性値2 # @return [Meteor::Element] element(要素) # @overload element(elm) # mirror element (要素を射影する) # @param [Meteor::Element] elm element(要素) # @return [Meteor::Element] element(要素) # def element(elm = nil, attrs = nil,*args) #case args.length #when ZERO if !elm && !attrs @parser.element(self) else @parser.element(elm, attrs,*args) end end alias :child :element # # get elements (要素を取得する) # @overload elements(tag) # get elements using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @return [Array<Meteor::Element>] element array(要素配列) # @overload elements(tag,attrs) # get elements using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attrs) # get elements using attribute map (属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(tag,attr_name,attr_value) # get elements using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attr_name,attr_value) # get elements using attribute(name="value") (属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String] attr_value attribute value (属性値) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(tag,attr_name1,attr_value1,attr_name2,attr_value2) # get elements using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Array<Meteor::Element>] element array (要素配列) # @overload elements(attr_name1,attr_value1,attr_name2,attr_value2) # get elements using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] attr_name1 attribute name1 (属性名1) # @param [String] attr_value1 attribute value1 (属性値1) # @param [String,Symbol] attr_name2 attribute name2 (属性名2) # @param [String] attr_value2 attribute value2 (属性値2) # @return [Array<Meteor::Element>] element array (要素配列) # def elements(*args) @parser.elements(*args) end # # get (child) elements using selector like css3(CSS3のようにセレクタを用いて(子)要素を取得する) # CSS3 selector partial support (CSS3セレクタの部分的サポート) # @param selector [String] selector (セレクタ) # @return [Array<Meteor::Element>] element (要素) # def find(selector) @parser.find(selector) end alias :css :find # # get cx(comment extension) tag (CX(コメント拡張)タグを取得する) # @overload cxtag(tag,id) # get cx(comment extension) tag using tag name and id attribute (タグ名とID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String,Symbol] tag tag name (タグ名) # @param [String] id id attribute value (ID属性値) # @return [Meteor::Element] element(要素) # @overload cxtag(id) # get cx(comment extension) tag using id attribute (ID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String] id id attribute value (ID属性値) # @return [Meteor::Element] element (要素) # def cxtag(*args) @parser.cxtag(*args) end # # @overload attr(attr) # set attribute of element (要素の属性をセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attr attribute (属性) # @return [Meteor::Element] element (要素) # @deprecated # @overload attr(attr_name,attr_value) # set attribute of element (要素の属性をセットする) # @param [String,Symbol] attr_name attribute name (属性名) # @param [String,true,false] attr_value attribute value (属性値) # @return [Meteor::Element] element (要素) # @overload attr(attr_name) # get attribute value of element (要素の属性値を取得する) # @param [String,Symbol] attr_name attribute name (属性名) # @return [String] attribute value (属性値) # def attr(attrs,*args) @parser.attr(self, attrs,*args) end # # set attribute of element (要素の属性をセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attr attribute (属性) # @return [Meteor::Element] element (要素) # def attr=(attr) @parser.attr(self,attr) end # # set attribute map (要素マップをセットする) # @param [Hash<String,String>,Hash<Symbol,String>] attrs attribute map (属性マップ) # @return [Meteor::Element] element (要素) def attrs=(attrs) @parser.attrs(self,attrs) end # # get attribute map (属性マップを取得する) # @return [Hash<String,String>,Hash<Symbol,String>] attribute map (属性マップ) # def attrs @parser.attrs(self) end # # @overload attr_map(attr_map) # set attribute map (属性マップをセットする) # @param [Meteor::AttributeMap] attr_map attribute map (属性マップ) # @return [Meteor::Element] element (要素) # @deprecated # @overload attr_map() # get attribute map (属性マップを取得する) # @return [Meteor::AttributeMap] attribute map (属性マップ) # def attr_map(*args) @parser.attr_map(self, *args) end # # set attribute map (属性マップをセットする) # @param [Meteor::AttributeMap] attr_map attribute map (属性マップ) # @return [Meteor::Element] element (要素) # def attr_map=(attr_map) @parser.attr_map(self,attr_map) end # # @overload content(content,entity_ref=true) # set content of element (要素の内容をセットする) # @param [String] content content of element (要素の内容) # @param [true,false] entity_ref entity reference flag (エンティティ参照フラグ) # @return [Meteor::Element] element (要素) # @deprecated # @overload content(content) # set content of element (要素の内容をセットする) # @param [String] content content of element (要素の内容) # @return [Meteor::Element] element (要素) # @deprecated # @overload content() # get content of element (要素の内容を取得する) # @return [String] content (内容) # def content(*args) @parser.content(self, *args) end # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def content=(value) @parser.content(self, value) end # # set attribute (属性をセットする) # @param [String,Symbol] name attribute name (属性の名前) # @param [String] value attribute value (属性の値) # @return [Meteor::Element] element (要素) # def []=(name, value) @parser.attr(self, name, value) end # # get attribute value (属性の値を取得する) # @param [String,Symbol] name attribute name (属性の名前) # @return [String] attribute value (属性の値) # def [](name) @parser.attr(self, name) end # # remove attribute of element (要素の属性を消す) # @param [String,Symbol] attr_name attribute name (属性名) # @return [Meteor::Element] element (要素) # def remove_attr(attr_name) @parser.remove_attr(self, attr_name) end # # remove element (要素を削除する) # def remove @parser.remove_element(self) end # # reflect (反映する) # def flush @parser.flush end # # @overload execute(hook) # run action of Hooker (Hookerクラスの処理を実行する) # @param [Meteor::Hook::Hooker] hook Hooker object (Hookerオブジェクト) # @overload execute(loop,list) # run action of Looper (Looperクラスの処理を実行する) # @param [Meteor::Hook::Looper] loop Looper object (Looperオブジェクト) # @param [Array] list 配列 # def execute(*args) @parser.execute(self, *args) end end |
Class Method Details
.new!(elm, ps) ⇒ Meteor::Element
make copy (コピーを作成する)
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/meteor.rb', line 187 def self.new!(*args) case args.length when TWO @obj = args[1].element_hook if @obj @obj.attributes = String.new(args[0].attributes) @obj.mixed_content = String.new(args[0].mixed_content) #@obj.pattern = String.new(args[0].pattern) @obj.document = String.new(args[0].document) @obj else @obj = self.new(args[0], args[1]) args[1].element_hook = @obj @obj end else raise ArgumentError end end |
Instance Method Details
#[](name) ⇒ String
get attribute value (属性の値を取得する)
523 524 525 |
# File 'lib/meteor.rb', line 523 def [](name) @parser.attr(self, name) end |
#[]=(name, value) ⇒ Meteor::Element
set attribute (属性をセットする)
514 515 516 |
# File 'lib/meteor.rb', line 514 def []=(name, value) @parser.attr(self, name, value) end |
#attr(attr) ⇒ Meteor::Element #attr(attr_name, attr_value) ⇒ Meteor::Element #attr(attr_name) ⇒ String
427 428 429 |
# File 'lib/meteor.rb', line 427 def attr(attrs,*args) @parser.attr(self, attrs,*args) end |
#attr=(attr) ⇒ Meteor::Element
set attribute of element (要素の属性をセットする)
436 437 438 |
# File 'lib/meteor.rb', line 436 def attr=(attr) @parser.attr(self,attr) end |
#attr_map(attr_map) ⇒ Meteor::Element #attr_map ⇒ Meteor::AttributeMap
466 467 468 |
# File 'lib/meteor.rb', line 466 def attr_map(*args) @parser.attr_map(self, *args) end |
#attr_map=(attr_map) ⇒ Meteor::Element
set attribute map (属性マップをセットする)
475 476 477 |
# File 'lib/meteor.rb', line 475 def attr_map=(attr_map) @parser.attr_map(self,attr_map) end |
#attrs ⇒ Hash<String,String>, Hash<Symbol,String>
get attribute map (属性マップを取得する)
452 453 454 |
# File 'lib/meteor.rb', line 452 def attrs @parser.attrs(self) end |
#attrs=(attrs) ⇒ Meteor::Element
set attribute map (要素マップをセットする)
444 445 446 |
# File 'lib/meteor.rb', line 444 def attrs=(attrs) @parser.attrs(self,attrs) end |
#clone ⇒ Meteor::Element
clone (複製する)
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/meteor.rb', line 211 def clone obj = self.parser.element_cache[self.object_id] if obj obj.attributes = String.new(self.attributes) obj.mixed_content = String.new(self.mixed_content) #obj.pattern = String.new(self.pattern) obj.document = String.new(self.document) obj.usable = true obj else obj = self.new(self) self.parser.element_cache[self.object_id] = obj obj end end |
#content(content, entity_ref = true) ⇒ Meteor::Element #content(content) ⇒ Meteor::Element #content ⇒ String
495 496 497 |
# File 'lib/meteor.rb', line 495 def content(*args) @parser.content(self, *args) end |
#content=(value) ⇒ Meteor::Element
set content of element (要素の内容をセットする)
504 505 506 |
# File 'lib/meteor.rb', line 504 def content=(value) @parser.content(self, value) end |
#cxtag(tag, id) ⇒ Meteor::Element #cxtag(id) ⇒ Meteor::Element
get cx(comment extension) tag (CX(コメント拡張)タグを取得する)
407 408 409 |
# File 'lib/meteor.rb', line 407 def cxtag(*args) @parser.cxtag(*args) end |
#document ⇒ String
get document (ドキュメントを取得する)
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/meteor.rb', line 240 def document if @document_sync @document_sync = false case @parser.doc_type when Parser::HTML, Parser::HTML5 if @cx #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4 @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->" else if @empty #@pattern_cc = '' << TAG_OPEN << elm.tag << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.tag << TAG_CLOSE @document = "<#{@tag}#{@attributes}>#{@mixed_content}</#{@tag}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @tag << @attributes << Meteor::Core::Kernel::TAG_CLOSE #@document = "<#{@name}#{@attributes}>" end end when Parser::XHTML, Parser::XHTML5, Parser::XML if @cx #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4 @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->" else if @empty #@pattern_cc = '' << TAG_OPEN << elm.tag << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.tag << TAG_CLOSE @document = "<#{@tag}#{@attributes}>#{@mixed_content}</#{@tag}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @tag << @attributes << Meteor::Core::Kernel::TAG_CLOSE3 #@document = "<#{@name}#{@attributes}/>" end end end else @document end end |
#document=(doc) ⇒ Object
set document (ドキュメントをセットする)
231 232 233 234 |
# File 'lib/meteor.rb', line 231 def document=(doc) @document_sync = false @document = doc end |
#element ⇒ Meteor::Element #element(tag) ⇒ Meteor::Element #element(tag, attrs) ⇒ Meteor::Element #element(attrs) ⇒ Meteor::Element #element(tag, attr_name, attr_value) ⇒ Meteor::Element #element(attr_name, attr_value) ⇒ Meteor::Element #element(tag, attr_name1, attr_value1, attr_name2, attr_value2) ⇒ Meteor::Element #element(attr_name1, attr_value1, attr_name2, attr_value2) ⇒ Meteor::Element #element(elm) ⇒ Meteor::Element Also known as: child
get element (要素を取得する)
325 326 327 328 329 330 331 332 333 |
# File 'lib/meteor.rb', line 325 def element(elm = nil, attrs = nil,*args) #case args.length #when ZERO if !elm && !attrs @parser.element(self) else @parser.element(elm, attrs,*args) end end |
#elements(tag) ⇒ Array<Meteor::Element> #elements(tag, attrs) ⇒ Array<Meteor::Element> #elements(attrs) ⇒ Array<Meteor::Element> #elements(tag, attr_name, attr_value) ⇒ Array<Meteor::Element> #elements(attr_name, attr_value) ⇒ Array<Meteor::Element> #elements(tag, attr_name1, attr_value1, attr_name2, attr_value2) ⇒ Array<Meteor::Element> #elements(attr_name1, attr_value1, attr_name2, attr_value2) ⇒ Array<Meteor::Element>
get elements (要素を取得する)
379 380 381 |
# File 'lib/meteor.rb', line 379 def elements(*args) @parser.elements(*args) end |
#execute(hook) ⇒ Object #execute(loop, list) ⇒ Object
559 560 561 |
# File 'lib/meteor.rb', line 559 def execute(*args) @parser.execute(self, *args) end |
#find(selector) ⇒ Array<Meteor::Element> Also known as: css
get (child) elements using selector like css3(CSS3のようにセレクタを用いて(子)要素を取得する) CSS3 selector partial support (CSS3セレクタの部分的サポート)
389 390 391 |
# File 'lib/meteor.rb', line 389 def find(selector) @parser.find(selector) end |
#flush ⇒ Object
reflect (反映する)
546 547 548 |
# File 'lib/meteor.rb', line 546 def flush @parser.flush end |
#remove ⇒ Object
remove element (要素を削除する)
539 540 541 |
# File 'lib/meteor.rb', line 539 def remove @parser.remove_element(self) end |
#remove_attr(attr_name) ⇒ Meteor::Element
remove attribute of element (要素の属性を消す)
532 533 534 |
# File 'lib/meteor.rb', line 532 def remove_attr(attr_name) @parser.remove_attr(self, attr_name) end |