Class: Meteor::Element
- Inherits:
-
Object
- Object
- Meteor::Element
- Defined in:
- lib/meteor/element.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 (ドキュメント更新フラグ).
-
#mixed_content ⇒ String
Content (内容).
-
#name ⇒ String
(also: #tag)
Tag name (要素名).
-
#non_nest ⇒ true, false
(also: #mono)
Child non-nest flag (非入れ子フラグ).
-
#normal ⇒ true, false
(also: #empty)
Content normal 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
Deletion flag (削除フラグ).
-
#type_value ⇒ String
Type (タイプ属性).
-
#usable ⇒ true, false
Usable flag (有効・無効フラグ).
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(*args) ⇒ Object
clone (複製する).
- #content(*args) ⇒ Object (also: #text)
-
#content=(value) ⇒ Meteor::Element
(also: #text=)
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セレクタの部分的サポート).
-
#flash ⇒ Object
(also: #flush)
reflect (反映する).
-
#initialize(*args) ⇒ Element
constructor
initializer (イニシャライザ).
-
#remove ⇒ Object
remove element (要素を削除する).
-
#remove_attr(attr_name) ⇒ Meteor::Element
remove attribute of element (要素の属性を消す).
-
#unsafe_content=(value) ⇒ Meteor::Element
(also: #unsafe_text=)
set content of element (要素の内容をセットする).
Constructor Details
#initialize(name) ⇒ Element #initialize(elm) ⇒ Element #initialize(elm, ps) ⇒ Element
initializer (イニシャライザ)
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/meteor/element.rb', line 62 def initialize(*args) case args.length when Meteor::ONE if args[0].is_a?(String) initialize_s(args[0]) elsif args[0].is_a?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when Meteor::TWO initialize_two(args[0], args[1]) when Meteor::ZERO else raise ArgumentError end end |
Instance Attribute Details
#attributes ⇒ String
Returns attributes (属性群).
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 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 |
# File 'lib/meteor/element.rb', line 39 class Element attr_accessor :name, :attributes, :mixed_content, :raw_content, :pattern, :document_sync, :normal, :cx, :non_nest, :parser, :type_value, :usable, :origin, :copy, :removed alias tag name alias tag= name= alias empty normal alias empty= normal= alias mono non_nest alias mono= non_nest= # # initializer (イニシャライザ) # @overload initialize(name) # @param [String,Symbol] name 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 Meteor::ONE if args[0].is_a?(String) initialize_s(args[0]) elsif args[0].is_a?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when Meteor::TWO initialize_two(args[0], args[1]) when Meteor::ZERO else raise ArgumentError end end # # initializer (イニシャライザ) # @param [String] name tag name (タグ名) # def initialize_s(name) @name = name # @attributes = nil # @mixed_content = nil # @pattern = nil # @document = nil # @parser=nil # @normal = false # @cx = false # @non_nest = false # @parent = false @usable = true end private :initialize_s # # initializer (イニシャライザ) # @param [Meteor::Element] elm element (要素) # def initialize_e(elm) initialize_two(elm, elm.parser) @usable = true end private :initialize_e def initialize_two(elm, ps) @parser = ps if normal ps.element(elm) else @name = elm.name @attributes = String.new(elm.attributes) @mixed_content = String.new(elm.mixed_content) # @pattern = String.new(elm.pattern) @pattern = elm.pattern @document = String.new(elm.document) @normal = elm.normal @cx = elm.cx @non_nest = elm.non_nest @origin = elm # @usable = false elm.copy = self end end private :initialize_two # # clone (複製する) # @overload clone() # @return [Meteor::Element] element (要素) # @overload clone(ps) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def clone(*args) case args.length when Meteor::ZERO clone_zero when Meteor::ONE clone_one(args[0]) end end # # clone (複製する) # @return [Meteor::Element] element (要素) # def clone_zero obj = parser.element_cache[object_id] if obj obj.attributes = String.new(attributes) obj.mixed_content = String.new(mixed_content) # obj.pattern = String.new(self.pattern) obj.document = String.new(document) obj.usable = true else obj = self.class.new(self) parser.element_cache[object_id] = obj end obj end private :clone_zero # # clone (複製する) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def clone_one(ps) obj = ps.element_hook if obj obj.attributes = String.new(attributes) obj.mixed_content = String.new(mixed_content) # obj.pattern = String.new(self.pattern) obj.document = String.new(document) else obj = self.class.new(self, ps) ps.element_hook = obj end obj end private :clone_one # # 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::HTML4 if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '>' # @document = "<#{@name}#{@attributes}>" end when Parser::XHTML, Parser::XHTML4, Parser::XML if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '/>' # @document = "<#{@name}#{@attributes}/>" end end else @document end end # # get element (要素を取得する) # @overload element() # get element (要素を取得する) # @return [Meteor::Element] element (要素) # @overload element(name) # get element using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] name tag name (タグ名) # @return [Meteor::Element] element (要素) # @overload element(name,attrs) # get element using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name,attr_value) # get element using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name1,attr_value1,attr_name2,attr_value2) # get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name) # get elements using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] name tag name (タグ名) # @return [Array<Meteor::Element>] element array(要素配列) # @overload elements(name,attrs) # get elements using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name,attr_value) # get elements using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name1,attr_value1,attr_name2,attr_value2) # get elements using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,id) # get cx(comment extension) tag using tag name and id attribute (タグ名とID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String,Symbol] name 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 alias text content # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def content=(value) @parser.content(self, value) end alias text= content= # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def unsafe_content=(value) @parser.content(self, value, false) end alias unsafe_text= unsafe_content= # # set attribute (属性をセットする) # @param [String,Symbol] name attribute name (属性の名前) # @param [String] value attribute value (属性の値) # @return [Meteor::Element] element (要素) # def []=(name, value) if !value.nil? @parser.attr(self, name, value) else @parser.remove_attr(self, name) end 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 flash @parser.flash end alias flush flash # # @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 (複製ポインタ).
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 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 |
# File 'lib/meteor/element.rb', line 39 class Element attr_accessor :name, :attributes, :mixed_content, :raw_content, :pattern, :document_sync, :normal, :cx, :non_nest, :parser, :type_value, :usable, :origin, :copy, :removed alias tag name alias tag= name= alias empty normal alias empty= normal= alias mono non_nest alias mono= non_nest= # # initializer (イニシャライザ) # @overload initialize(name) # @param [String,Symbol] name 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 Meteor::ONE if args[0].is_a?(String) initialize_s(args[0]) elsif args[0].is_a?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when Meteor::TWO initialize_two(args[0], args[1]) when Meteor::ZERO else raise ArgumentError end end # # initializer (イニシャライザ) # @param [String] name tag name (タグ名) # def initialize_s(name) @name = name # @attributes = nil # @mixed_content = nil # @pattern = nil # @document = nil # @parser=nil # @normal = false # @cx = false # @non_nest = false # @parent = false @usable = true end private :initialize_s # # initializer (イニシャライザ) # @param [Meteor::Element] elm element (要素) # def initialize_e(elm) initialize_two(elm, elm.parser) @usable = true end private :initialize_e def initialize_two(elm, ps) @parser = ps if normal ps.element(elm) else @name = elm.name @attributes = String.new(elm.attributes) @mixed_content = String.new(elm.mixed_content) # @pattern = String.new(elm.pattern) @pattern = elm.pattern @document = String.new(elm.document) @normal = elm.normal @cx = elm.cx @non_nest = elm.non_nest @origin = elm # @usable = false elm.copy = self end end private :initialize_two # # clone (複製する) # @overload clone() # @return [Meteor::Element] element (要素) # @overload clone(ps) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def clone(*args) case args.length when Meteor::ZERO clone_zero when Meteor::ONE clone_one(args[0]) end end # # clone (複製する) # @return [Meteor::Element] element (要素) # def clone_zero obj = parser.element_cache[object_id] if obj obj.attributes = String.new(attributes) obj.mixed_content = String.new(mixed_content) # obj.pattern = String.new(self.pattern) obj.document = String.new(document) obj.usable = true else obj = self.class.new(self) parser.element_cache[object_id] = obj end obj end private :clone_zero # # clone (複製する) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def clone_one(ps) obj = ps.element_hook if obj obj.attributes = String.new(attributes) obj.mixed_content = String.new(mixed_content) # obj.pattern = String.new(self.pattern) obj.document = String.new(document) else obj = self.class.new(self, ps) ps.element_hook = obj end obj end private :clone_one # # 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::HTML4 if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '>' # @document = "<#{@name}#{@attributes}>" end when Parser::XHTML, Parser::XHTML4, Parser::XML if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '/>' # @document = "<#{@name}#{@attributes}/>" end end else @document end end # # get element (要素を取得する) # @overload element() # get element (要素を取得する) # @return [Meteor::Element] element (要素) # @overload element(name) # get element using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] name tag name (タグ名) # @return [Meteor::Element] element (要素) # @overload element(name,attrs) # get element using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name,attr_value) # get element using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name1,attr_value1,attr_name2,attr_value2) # get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name) # get elements using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] name tag name (タグ名) # @return [Array<Meteor::Element>] element array(要素配列) # @overload elements(name,attrs) # get elements using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name,attr_value) # get elements using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name1,attr_value1,attr_name2,attr_value2) # get elements using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,id) # get cx(comment extension) tag using tag name and id attribute (タグ名とID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String,Symbol] name 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 alias text content # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def content=(value) @parser.content(self, value) end alias text= content= # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def unsafe_content=(value) @parser.content(self, value, false) end alias unsafe_text= unsafe_content= # # set attribute (属性をセットする) # @param [String,Symbol] name attribute name (属性の名前) # @param [String] value attribute value (属性の値) # @return [Meteor::Element] element (要素) # def []=(name, value) if !value.nil? @parser.attr(self, name, value) else @parser.remove_attr(self, name) end 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 flash @parser.flash end alias flush flash # # @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 (コメント拡張タグフラグ).
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 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 |
# File 'lib/meteor/element.rb', line 39 class Element attr_accessor :name, :attributes, :mixed_content, :raw_content, :pattern, :document_sync, :normal, :cx, :non_nest, :parser, :type_value, :usable, :origin, :copy, :removed alias tag name alias tag= name= alias empty normal alias empty= normal= alias mono non_nest alias mono= non_nest= # # initializer (イニシャライザ) # @overload initialize(name) # @param [String,Symbol] name 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 Meteor::ONE if args[0].is_a?(String) initialize_s(args[0]) elsif args[0].is_a?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when Meteor::TWO initialize_two(args[0], args[1]) when Meteor::ZERO else raise ArgumentError end end # # initializer (イニシャライザ) # @param [String] name tag name (タグ名) # def initialize_s(name) @name = name # @attributes = nil # @mixed_content = nil # @pattern = nil # @document = nil # @parser=nil # @normal = false # @cx = false # @non_nest = false # @parent = false @usable = true end private :initialize_s # # initializer (イニシャライザ) # @param [Meteor::Element] elm element (要素) # def initialize_e(elm) initialize_two(elm, elm.parser) @usable = true end private :initialize_e def initialize_two(elm, ps) @parser = ps if normal ps.element(elm) else @name = elm.name @attributes = String.new(elm.attributes) @mixed_content = String.new(elm.mixed_content) # @pattern = String.new(elm.pattern) @pattern = elm.pattern @document = String.new(elm.document) @normal = elm.normal @cx = elm.cx @non_nest = elm.non_nest @origin = elm # @usable = false elm.copy = self end end private :initialize_two # # clone (複製する) # @overload clone() # @return [Meteor::Element] element (要素) # @overload clone(ps) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def clone(*args) case args.length when Meteor::ZERO clone_zero when Meteor::ONE clone_one(args[0]) end end # # clone (複製する) # @return [Meteor::Element] element (要素) # def clone_zero obj = parser.element_cache[object_id] if obj obj.attributes = String.new(attributes) obj.mixed_content = String.new(mixed_content) # obj.pattern = String.new(self.pattern) obj.document = String.new(document) obj.usable = true else obj = self.class.new(self) parser.element_cache[object_id] = obj end obj end private :clone_zero # # clone (複製する) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def clone_one(ps) obj = ps.element_hook if obj obj.attributes = String.new(attributes) obj.mixed_content = String.new(mixed_content) # obj.pattern = String.new(self.pattern) obj.document = String.new(document) else obj = self.class.new(self, ps) ps.element_hook = obj end obj end private :clone_one # # 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::HTML4 if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '>' # @document = "<#{@name}#{@attributes}>" end when Parser::XHTML, Parser::XHTML4, Parser::XML if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '/>' # @document = "<#{@name}#{@attributes}/>" end end else @document end end # # get element (要素を取得する) # @overload element() # get element (要素を取得する) # @return [Meteor::Element] element (要素) # @overload element(name) # get element using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] name tag name (タグ名) # @return [Meteor::Element] element (要素) # @overload element(name,attrs) # get element using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name,attr_value) # get element using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name1,attr_value1,attr_name2,attr_value2) # get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name) # get elements using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] name tag name (タグ名) # @return [Array<Meteor::Element>] element array(要素配列) # @overload elements(name,attrs) # get elements using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name,attr_value) # get elements using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name1,attr_value1,attr_name2,attr_value2) # get elements using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,id) # get cx(comment extension) tag using tag name and id attribute (タグ名とID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String,Symbol] name 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 alias text content # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def content=(value) @parser.content(self, value) end alias text= content= # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def unsafe_content=(value) @parser.content(self, value, false) end alias unsafe_text= unsafe_content= # # set attribute (属性をセットする) # @param [String,Symbol] name attribute name (属性の名前) # @param [String] value attribute value (属性の値) # @return [Meteor::Element] element (要素) # def []=(name, value) if !value.nil? @parser.attr(self, name, value) else @parser.remove_attr(self, name) end 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 flash @parser.flash end alias flush flash # # @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 (ドキュメント更新フラグ).
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 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 |
# File 'lib/meteor/element.rb', line 39 class Element attr_accessor :name, :attributes, :mixed_content, :raw_content, :pattern, :document_sync, :normal, :cx, :non_nest, :parser, :type_value, :usable, :origin, :copy, :removed alias tag name alias tag= name= alias empty normal alias empty= normal= alias mono non_nest alias mono= non_nest= # # initializer (イニシャライザ) # @overload initialize(name) # @param [String,Symbol] name 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 Meteor::ONE if args[0].is_a?(String) initialize_s(args[0]) elsif args[0].is_a?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when Meteor::TWO initialize_two(args[0], args[1]) when Meteor::ZERO else raise ArgumentError end end # # initializer (イニシャライザ) # @param [String] name tag name (タグ名) # def initialize_s(name) @name = name # @attributes = nil # @mixed_content = nil # @pattern = nil # @document = nil # @parser=nil # @normal = false # @cx = false # @non_nest = false # @parent = false @usable = true end private :initialize_s # # initializer (イニシャライザ) # @param [Meteor::Element] elm element (要素) # def initialize_e(elm) initialize_two(elm, elm.parser) @usable = true end private :initialize_e def initialize_two(elm, ps) @parser = ps if normal ps.element(elm) else @name = elm.name @attributes = String.new(elm.attributes) @mixed_content = String.new(elm.mixed_content) # @pattern = String.new(elm.pattern) @pattern = elm.pattern @document = String.new(elm.document) @normal = elm.normal @cx = elm.cx @non_nest = elm.non_nest @origin = elm # @usable = false elm.copy = self end end private :initialize_two # # clone (複製する) # @overload clone() # @return [Meteor::Element] element (要素) # @overload clone(ps) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def clone(*args) case args.length when Meteor::ZERO clone_zero when Meteor::ONE clone_one(args[0]) end end # # clone (複製する) # @return [Meteor::Element] element (要素) # def clone_zero obj = parser.element_cache[object_id] if obj obj.attributes = String.new(attributes) obj.mixed_content = String.new(mixed_content) # obj.pattern = String.new(self.pattern) obj.document = String.new(document) obj.usable = true else obj = self.class.new(self) parser.element_cache[object_id] = obj end obj end private :clone_zero # # clone (複製する) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def clone_one(ps) obj = ps.element_hook if obj obj.attributes = String.new(attributes) obj.mixed_content = String.new(mixed_content) # obj.pattern = String.new(self.pattern) obj.document = String.new(document) else obj = self.class.new(self, ps) ps.element_hook = obj end obj end private :clone_one # # 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::HTML4 if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '>' # @document = "<#{@name}#{@attributes}>" end when Parser::XHTML, Parser::XHTML4, Parser::XML if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '/>' # @document = "<#{@name}#{@attributes}/>" end end else @document end end # # get element (要素を取得する) # @overload element() # get element (要素を取得する) # @return [Meteor::Element] element (要素) # @overload element(name) # get element using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] name tag name (タグ名) # @return [Meteor::Element] element (要素) # @overload element(name,attrs) # get element using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name,attr_value) # get element using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name1,attr_value1,attr_name2,attr_value2) # get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name) # get elements using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] name tag name (タグ名) # @return [Array<Meteor::Element>] element array(要素配列) # @overload elements(name,attrs) # get elements using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name,attr_value) # get elements using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name1,attr_value1,attr_name2,attr_value2) # get elements using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,id) # get cx(comment extension) tag using tag name and id attribute (タグ名とID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String,Symbol] name 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 alias text content # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def content=(value) @parser.content(self, value) end alias text= content= # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def unsafe_content=(value) @parser.content(self, value, false) end alias unsafe_text= unsafe_content= # # set attribute (属性をセットする) # @param [String,Symbol] name attribute name (属性の名前) # @param [String] value attribute value (属性の値) # @return [Meteor::Element] element (要素) # def []=(name, value) if !value.nil? @parser.attr(self, name, value) else @parser.remove_attr(self, name) end 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 flash @parser.flash end alias flush flash # # @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 (内容).
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 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 |
# File 'lib/meteor/element.rb', line 39 class Element attr_accessor :name, :attributes, :mixed_content, :raw_content, :pattern, :document_sync, :normal, :cx, :non_nest, :parser, :type_value, :usable, :origin, :copy, :removed alias tag name alias tag= name= alias empty normal alias empty= normal= alias mono non_nest alias mono= non_nest= # # initializer (イニシャライザ) # @overload initialize(name) # @param [String,Symbol] name 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 Meteor::ONE if args[0].is_a?(String) initialize_s(args[0]) elsif args[0].is_a?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when Meteor::TWO initialize_two(args[0], args[1]) when Meteor::ZERO else raise ArgumentError end end # # initializer (イニシャライザ) # @param [String] name tag name (タグ名) # def initialize_s(name) @name = name # @attributes = nil # @mixed_content = nil # @pattern = nil # @document = nil # @parser=nil # @normal = false # @cx = false # @non_nest = false # @parent = false @usable = true end private :initialize_s # # initializer (イニシャライザ) # @param [Meteor::Element] elm element (要素) # def initialize_e(elm) initialize_two(elm, elm.parser) @usable = true end private :initialize_e def initialize_two(elm, ps) @parser = ps if normal ps.element(elm) else @name = elm.name @attributes = String.new(elm.attributes) @mixed_content = String.new(elm.mixed_content) # @pattern = String.new(elm.pattern) @pattern = elm.pattern @document = String.new(elm.document) @normal = elm.normal @cx = elm.cx @non_nest = elm.non_nest @origin = elm # @usable = false elm.copy = self end end private :initialize_two # # clone (複製する) # @overload clone() # @return [Meteor::Element] element (要素) # @overload clone(ps) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def clone(*args) case args.length when Meteor::ZERO clone_zero when Meteor::ONE clone_one(args[0]) end end # # clone (複製する) # @return [Meteor::Element] element (要素) # def clone_zero obj = parser.element_cache[object_id] if obj obj.attributes = String.new(attributes) obj.mixed_content = String.new(mixed_content) # obj.pattern = String.new(self.pattern) obj.document = String.new(document) obj.usable = true else obj = self.class.new(self) parser.element_cache[object_id] = obj end obj end private :clone_zero # # clone (複製する) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def clone_one(ps) obj = ps.element_hook if obj obj.attributes = String.new(attributes) obj.mixed_content = String.new(mixed_content) # obj.pattern = String.new(self.pattern) obj.document = String.new(document) else obj = self.class.new(self, ps) ps.element_hook = obj end obj end private :clone_one # # 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::HTML4 if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '>' # @document = "<#{@name}#{@attributes}>" end when Parser::XHTML, Parser::XHTML4, Parser::XML if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '/>' # @document = "<#{@name}#{@attributes}/>" end end else @document end end # # get element (要素を取得する) # @overload element() # get element (要素を取得する) # @return [Meteor::Element] element (要素) # @overload element(name) # get element using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] name tag name (タグ名) # @return [Meteor::Element] element (要素) # @overload element(name,attrs) # get element using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name,attr_value) # get element using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name1,attr_value1,attr_name2,attr_value2) # get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name) # get elements using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] name tag name (タグ名) # @return [Array<Meteor::Element>] element array(要素配列) # @overload elements(name,attrs) # get elements using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name,attr_value) # get elements using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name1,attr_value1,attr_name2,attr_value2) # get elements using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,id) # get cx(comment extension) tag using tag name and id attribute (タグ名とID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String,Symbol] name 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 alias text content # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def content=(value) @parser.content(self, value) end alias text= content= # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def unsafe_content=(value) @parser.content(self, value, false) end alias unsafe_text= unsafe_content= # # set attribute (属性をセットする) # @param [String,Symbol] name attribute name (属性の名前) # @param [String] value attribute value (属性の値) # @return [Meteor::Element] element (要素) # def []=(name, value) if !value.nil? @parser.attr(self, name, value) else @parser.remove_attr(self, name) end 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 flash @parser.flash end alias flush flash # # @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 |
#name ⇒ String Also known as: tag
Returns tag name (要素名).
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 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 |
# File 'lib/meteor/element.rb', line 39 class Element attr_accessor :name, :attributes, :mixed_content, :raw_content, :pattern, :document_sync, :normal, :cx, :non_nest, :parser, :type_value, :usable, :origin, :copy, :removed alias tag name alias tag= name= alias empty normal alias empty= normal= alias mono non_nest alias mono= non_nest= # # initializer (イニシャライザ) # @overload initialize(name) # @param [String,Symbol] name 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 Meteor::ONE if args[0].is_a?(String) initialize_s(args[0]) elsif args[0].is_a?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when Meteor::TWO initialize_two(args[0], args[1]) when Meteor::ZERO else raise ArgumentError end end # # initializer (イニシャライザ) # @param [String] name tag name (タグ名) # def initialize_s(name) @name = name # @attributes = nil # @mixed_content = nil # @pattern = nil # @document = nil # @parser=nil # @normal = false # @cx = false # @non_nest = false # @parent = false @usable = true end private :initialize_s # # initializer (イニシャライザ) # @param [Meteor::Element] elm element (要素) # def initialize_e(elm) initialize_two(elm, elm.parser) @usable = true end private :initialize_e def initialize_two(elm, ps) @parser = ps if normal ps.element(elm) else @name = elm.name @attributes = String.new(elm.attributes) @mixed_content = String.new(elm.mixed_content) # @pattern = String.new(elm.pattern) @pattern = elm.pattern @document = String.new(elm.document) @normal = elm.normal @cx = elm.cx @non_nest = elm.non_nest @origin = elm # @usable = false elm.copy = self end end private :initialize_two # # clone (複製する) # @overload clone() # @return [Meteor::Element] element (要素) # @overload clone(ps) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def clone(*args) case args.length when Meteor::ZERO clone_zero when Meteor::ONE clone_one(args[0]) end end # # clone (複製する) # @return [Meteor::Element] element (要素) # def clone_zero obj = parser.element_cache[object_id] if obj obj.attributes = String.new(attributes) obj.mixed_content = String.new(mixed_content) # obj.pattern = String.new(self.pattern) obj.document = String.new(document) obj.usable = true else obj = self.class.new(self) parser.element_cache[object_id] = obj end obj end private :clone_zero # # clone (複製する) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def clone_one(ps) obj = ps.element_hook if obj obj.attributes = String.new(attributes) obj.mixed_content = String.new(mixed_content) # obj.pattern = String.new(self.pattern) obj.document = String.new(document) else obj = self.class.new(self, ps) ps.element_hook = obj end obj end private :clone_one # # 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::HTML4 if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '>' # @document = "<#{@name}#{@attributes}>" end when Parser::XHTML, Parser::XHTML4, Parser::XML if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '/>' # @document = "<#{@name}#{@attributes}/>" end end else @document end end # # get element (要素を取得する) # @overload element() # get element (要素を取得する) # @return [Meteor::Element] element (要素) # @overload element(name) # get element using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] name tag name (タグ名) # @return [Meteor::Element] element (要素) # @overload element(name,attrs) # get element using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name,attr_value) # get element using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name1,attr_value1,attr_name2,attr_value2) # get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name) # get elements using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] name tag name (タグ名) # @return [Array<Meteor::Element>] element array(要素配列) # @overload elements(name,attrs) # get elements using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name,attr_value) # get elements using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name1,attr_value1,attr_name2,attr_value2) # get elements using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,id) # get cx(comment extension) tag using tag name and id attribute (タグ名とID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String,Symbol] name 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 alias text content # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def content=(value) @parser.content(self, value) end alias text= content= # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def unsafe_content=(value) @parser.content(self, value, false) end alias unsafe_text= unsafe_content= # # set attribute (属性をセットする) # @param [String,Symbol] name attribute name (属性の名前) # @param [String] value attribute value (属性の値) # @return [Meteor::Element] element (要素) # def []=(name, value) if !value.nil? @parser.attr(self, name, value) else @parser.remove_attr(self, name) end 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 flash @parser.flash end alias flush flash # # @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 |
#non_nest ⇒ true, false Also known as: mono
Returns child non-nest flag (非入れ子フラグ).
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 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 |
# File 'lib/meteor/element.rb', line 39 class Element attr_accessor :name, :attributes, :mixed_content, :raw_content, :pattern, :document_sync, :normal, :cx, :non_nest, :parser, :type_value, :usable, :origin, :copy, :removed alias tag name alias tag= name= alias empty normal alias empty= normal= alias mono non_nest alias mono= non_nest= # # initializer (イニシャライザ) # @overload initialize(name) # @param [String,Symbol] name 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 Meteor::ONE if args[0].is_a?(String) initialize_s(args[0]) elsif args[0].is_a?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when Meteor::TWO initialize_two(args[0], args[1]) when Meteor::ZERO else raise ArgumentError end end # # initializer (イニシャライザ) # @param [String] name tag name (タグ名) # def initialize_s(name) @name = name # @attributes = nil # @mixed_content = nil # @pattern = nil # @document = nil # @parser=nil # @normal = false # @cx = false # @non_nest = false # @parent = false @usable = true end private :initialize_s # # initializer (イニシャライザ) # @param [Meteor::Element] elm element (要素) # def initialize_e(elm) initialize_two(elm, elm.parser) @usable = true end private :initialize_e def initialize_two(elm, ps) @parser = ps if normal ps.element(elm) else @name = elm.name @attributes = String.new(elm.attributes) @mixed_content = String.new(elm.mixed_content) # @pattern = String.new(elm.pattern) @pattern = elm.pattern @document = String.new(elm.document) @normal = elm.normal @cx = elm.cx @non_nest = elm.non_nest @origin = elm # @usable = false elm.copy = self end end private :initialize_two # # clone (複製する) # @overload clone() # @return [Meteor::Element] element (要素) # @overload clone(ps) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def clone(*args) case args.length when Meteor::ZERO clone_zero when Meteor::ONE clone_one(args[0]) end end # # clone (複製する) # @return [Meteor::Element] element (要素) # def clone_zero obj = parser.element_cache[object_id] if obj obj.attributes = String.new(attributes) obj.mixed_content = String.new(mixed_content) # obj.pattern = String.new(self.pattern) obj.document = String.new(document) obj.usable = true else obj = self.class.new(self) parser.element_cache[object_id] = obj end obj end private :clone_zero # # clone (複製する) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def clone_one(ps) obj = ps.element_hook if obj obj.attributes = String.new(attributes) obj.mixed_content = String.new(mixed_content) # obj.pattern = String.new(self.pattern) obj.document = String.new(document) else obj = self.class.new(self, ps) ps.element_hook = obj end obj end private :clone_one # # 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::HTML4 if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '>' # @document = "<#{@name}#{@attributes}>" end when Parser::XHTML, Parser::XHTML4, Parser::XML if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '/>' # @document = "<#{@name}#{@attributes}/>" end end else @document end end # # get element (要素を取得する) # @overload element() # get element (要素を取得する) # @return [Meteor::Element] element (要素) # @overload element(name) # get element using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] name tag name (タグ名) # @return [Meteor::Element] element (要素) # @overload element(name,attrs) # get element using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name,attr_value) # get element using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name1,attr_value1,attr_name2,attr_value2) # get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name) # get elements using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] name tag name (タグ名) # @return [Array<Meteor::Element>] element array(要素配列) # @overload elements(name,attrs) # get elements using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name,attr_value) # get elements using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name1,attr_value1,attr_name2,attr_value2) # get elements using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,id) # get cx(comment extension) tag using tag name and id attribute (タグ名とID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String,Symbol] name 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 alias text content # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def content=(value) @parser.content(self, value) end alias text= content= # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def unsafe_content=(value) @parser.content(self, value, false) end alias unsafe_text= unsafe_content= # # set attribute (属性をセットする) # @param [String,Symbol] name attribute name (属性の名前) # @param [String] value attribute value (属性の値) # @return [Meteor::Element] element (要素) # def []=(name, value) if !value.nil? @parser.attr(self, name, value) else @parser.remove_attr(self, name) end 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 flash @parser.flash end alias flush flash # # @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 |
#normal ⇒ true, false Also known as: empty
Returns content normal flag (内容存在フラグ).
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 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 |
# File 'lib/meteor/element.rb', line 39 class Element attr_accessor :name, :attributes, :mixed_content, :raw_content, :pattern, :document_sync, :normal, :cx, :non_nest, :parser, :type_value, :usable, :origin, :copy, :removed alias tag name alias tag= name= alias empty normal alias empty= normal= alias mono non_nest alias mono= non_nest= # # initializer (イニシャライザ) # @overload initialize(name) # @param [String,Symbol] name 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 Meteor::ONE if args[0].is_a?(String) initialize_s(args[0]) elsif args[0].is_a?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when Meteor::TWO initialize_two(args[0], args[1]) when Meteor::ZERO else raise ArgumentError end end # # initializer (イニシャライザ) # @param [String] name tag name (タグ名) # def initialize_s(name) @name = name # @attributes = nil # @mixed_content = nil # @pattern = nil # @document = nil # @parser=nil # @normal = false # @cx = false # @non_nest = false # @parent = false @usable = true end private :initialize_s # # initializer (イニシャライザ) # @param [Meteor::Element] elm element (要素) # def initialize_e(elm) initialize_two(elm, elm.parser) @usable = true end private :initialize_e def initialize_two(elm, ps) @parser = ps if normal ps.element(elm) else @name = elm.name @attributes = String.new(elm.attributes) @mixed_content = String.new(elm.mixed_content) # @pattern = String.new(elm.pattern) @pattern = elm.pattern @document = String.new(elm.document) @normal = elm.normal @cx = elm.cx @non_nest = elm.non_nest @origin = elm # @usable = false elm.copy = self end end private :initialize_two # # clone (複製する) # @overload clone() # @return [Meteor::Element] element (要素) # @overload clone(ps) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def clone(*args) case args.length when Meteor::ZERO clone_zero when Meteor::ONE clone_one(args[0]) end end # # clone (複製する) # @return [Meteor::Element] element (要素) # def clone_zero obj = parser.element_cache[object_id] if obj obj.attributes = String.new(attributes) obj.mixed_content = String.new(mixed_content) # obj.pattern = String.new(self.pattern) obj.document = String.new(document) obj.usable = true else obj = self.class.new(self) parser.element_cache[object_id] = obj end obj end private :clone_zero # # clone (複製する) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def clone_one(ps) obj = ps.element_hook if obj obj.attributes = String.new(attributes) obj.mixed_content = String.new(mixed_content) # obj.pattern = String.new(self.pattern) obj.document = String.new(document) else obj = self.class.new(self, ps) ps.element_hook = obj end obj end private :clone_one # # 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::HTML4 if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '>' # @document = "<#{@name}#{@attributes}>" end when Parser::XHTML, Parser::XHTML4, Parser::XML if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '/>' # @document = "<#{@name}#{@attributes}/>" end end else @document end end # # get element (要素を取得する) # @overload element() # get element (要素を取得する) # @return [Meteor::Element] element (要素) # @overload element(name) # get element using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] name tag name (タグ名) # @return [Meteor::Element] element (要素) # @overload element(name,attrs) # get element using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name,attr_value) # get element using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name1,attr_value1,attr_name2,attr_value2) # get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name) # get elements using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] name tag name (タグ名) # @return [Array<Meteor::Element>] element array(要素配列) # @overload elements(name,attrs) # get elements using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name,attr_value) # get elements using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name1,attr_value1,attr_name2,attr_value2) # get elements using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,id) # get cx(comment extension) tag using tag name and id attribute (タグ名とID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String,Symbol] name 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 alias text content # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def content=(value) @parser.content(self, value) end alias text= content= # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def unsafe_content=(value) @parser.content(self, value, false) end alias unsafe_text= unsafe_content= # # set attribute (属性をセットする) # @param [String,Symbol] name attribute name (属性の名前) # @param [String] value attribute value (属性の値) # @return [Meteor::Element] element (要素) # def []=(name, value) if !value.nil? @parser.attr(self, name, value) else @parser.remove_attr(self, name) end 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 flash @parser.flash end alias flush flash # # @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 (原本ポインタ).
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 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 |
# File 'lib/meteor/element.rb', line 39 class Element attr_accessor :name, :attributes, :mixed_content, :raw_content, :pattern, :document_sync, :normal, :cx, :non_nest, :parser, :type_value, :usable, :origin, :copy, :removed alias tag name alias tag= name= alias empty normal alias empty= normal= alias mono non_nest alias mono= non_nest= # # initializer (イニシャライザ) # @overload initialize(name) # @param [String,Symbol] name 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 Meteor::ONE if args[0].is_a?(String) initialize_s(args[0]) elsif args[0].is_a?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when Meteor::TWO initialize_two(args[0], args[1]) when Meteor::ZERO else raise ArgumentError end end # # initializer (イニシャライザ) # @param [String] name tag name (タグ名) # def initialize_s(name) @name = name # @attributes = nil # @mixed_content = nil # @pattern = nil # @document = nil # @parser=nil # @normal = false # @cx = false # @non_nest = false # @parent = false @usable = true end private :initialize_s # # initializer (イニシャライザ) # @param [Meteor::Element] elm element (要素) # def initialize_e(elm) initialize_two(elm, elm.parser) @usable = true end private :initialize_e def initialize_two(elm, ps) @parser = ps if normal ps.element(elm) else @name = elm.name @attributes = String.new(elm.attributes) @mixed_content = String.new(elm.mixed_content) # @pattern = String.new(elm.pattern) @pattern = elm.pattern @document = String.new(elm.document) @normal = elm.normal @cx = elm.cx @non_nest = elm.non_nest @origin = elm # @usable = false elm.copy = self end end private :initialize_two # # clone (複製する) # @overload clone() # @return [Meteor::Element] element (要素) # @overload clone(ps) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def clone(*args) case args.length when Meteor::ZERO clone_zero when Meteor::ONE clone_one(args[0]) end end # # clone (複製する) # @return [Meteor::Element] element (要素) # def clone_zero obj = parser.element_cache[object_id] if obj obj.attributes = String.new(attributes) obj.mixed_content = String.new(mixed_content) # obj.pattern = String.new(self.pattern) obj.document = String.new(document) obj.usable = true else obj = self.class.new(self) parser.element_cache[object_id] = obj end obj end private :clone_zero # # clone (複製する) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def clone_one(ps) obj = ps.element_hook if obj obj.attributes = String.new(attributes) obj.mixed_content = String.new(mixed_content) # obj.pattern = String.new(self.pattern) obj.document = String.new(document) else obj = self.class.new(self, ps) ps.element_hook = obj end obj end private :clone_one # # 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::HTML4 if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '>' # @document = "<#{@name}#{@attributes}>" end when Parser::XHTML, Parser::XHTML4, Parser::XML if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '/>' # @document = "<#{@name}#{@attributes}/>" end end else @document end end # # get element (要素を取得する) # @overload element() # get element (要素を取得する) # @return [Meteor::Element] element (要素) # @overload element(name) # get element using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] name tag name (タグ名) # @return [Meteor::Element] element (要素) # @overload element(name,attrs) # get element using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name,attr_value) # get element using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name1,attr_value1,attr_name2,attr_value2) # get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name) # get elements using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] name tag name (タグ名) # @return [Array<Meteor::Element>] element array(要素配列) # @overload elements(name,attrs) # get elements using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name,attr_value) # get elements using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name1,attr_value1,attr_name2,attr_value2) # get elements using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,id) # get cx(comment extension) tag using tag name and id attribute (タグ名とID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String,Symbol] name 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 alias text content # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def content=(value) @parser.content(self, value) end alias text= content= # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def unsafe_content=(value) @parser.content(self, value, false) end alias unsafe_text= unsafe_content= # # set attribute (属性をセットする) # @param [String,Symbol] name attribute name (属性の名前) # @param [String] value attribute value (属性の値) # @return [Meteor::Element] element (要素) # def []=(name, value) if !value.nil? @parser.attr(self, name, value) else @parser.remove_attr(self, name) end 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 flash @parser.flash end alias flush flash # # @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(パーサ).
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 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 |
# File 'lib/meteor/element.rb', line 39 class Element attr_accessor :name, :attributes, :mixed_content, :raw_content, :pattern, :document_sync, :normal, :cx, :non_nest, :parser, :type_value, :usable, :origin, :copy, :removed alias tag name alias tag= name= alias empty normal alias empty= normal= alias mono non_nest alias mono= non_nest= # # initializer (イニシャライザ) # @overload initialize(name) # @param [String,Symbol] name 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 Meteor::ONE if args[0].is_a?(String) initialize_s(args[0]) elsif args[0].is_a?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when Meteor::TWO initialize_two(args[0], args[1]) when Meteor::ZERO else raise ArgumentError end end # # initializer (イニシャライザ) # @param [String] name tag name (タグ名) # def initialize_s(name) @name = name # @attributes = nil # @mixed_content = nil # @pattern = nil # @document = nil # @parser=nil # @normal = false # @cx = false # @non_nest = false # @parent = false @usable = true end private :initialize_s # # initializer (イニシャライザ) # @param [Meteor::Element] elm element (要素) # def initialize_e(elm) initialize_two(elm, elm.parser) @usable = true end private :initialize_e def initialize_two(elm, ps) @parser = ps if normal ps.element(elm) else @name = elm.name @attributes = String.new(elm.attributes) @mixed_content = String.new(elm.mixed_content) # @pattern = String.new(elm.pattern) @pattern = elm.pattern @document = String.new(elm.document) @normal = elm.normal @cx = elm.cx @non_nest = elm.non_nest @origin = elm # @usable = false elm.copy = self end end private :initialize_two # # clone (複製する) # @overload clone() # @return [Meteor::Element] element (要素) # @overload clone(ps) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def clone(*args) case args.length when Meteor::ZERO clone_zero when Meteor::ONE clone_one(args[0]) end end # # clone (複製する) # @return [Meteor::Element] element (要素) # def clone_zero obj = parser.element_cache[object_id] if obj obj.attributes = String.new(attributes) obj.mixed_content = String.new(mixed_content) # obj.pattern = String.new(self.pattern) obj.document = String.new(document) obj.usable = true else obj = self.class.new(self) parser.element_cache[object_id] = obj end obj end private :clone_zero # # clone (複製する) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def clone_one(ps) obj = ps.element_hook if obj obj.attributes = String.new(attributes) obj.mixed_content = String.new(mixed_content) # obj.pattern = String.new(self.pattern) obj.document = String.new(document) else obj = self.class.new(self, ps) ps.element_hook = obj end obj end private :clone_one # # 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::HTML4 if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '>' # @document = "<#{@name}#{@attributes}>" end when Parser::XHTML, Parser::XHTML4, Parser::XML if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '/>' # @document = "<#{@name}#{@attributes}/>" end end else @document end end # # get element (要素を取得する) # @overload element() # get element (要素を取得する) # @return [Meteor::Element] element (要素) # @overload element(name) # get element using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] name tag name (タグ名) # @return [Meteor::Element] element (要素) # @overload element(name,attrs) # get element using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name,attr_value) # get element using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name1,attr_value1,attr_name2,attr_value2) # get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name) # get elements using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] name tag name (タグ名) # @return [Array<Meteor::Element>] element array(要素配列) # @overload elements(name,attrs) # get elements using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name,attr_value) # get elements using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name1,attr_value1,attr_name2,attr_value2) # get elements using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,id) # get cx(comment extension) tag using tag name and id attribute (タグ名とID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String,Symbol] name 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 alias text content # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def content=(value) @parser.content(self, value) end alias text= content= # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def unsafe_content=(value) @parser.content(self, value, false) end alias unsafe_text= unsafe_content= # # set attribute (属性をセットする) # @param [String,Symbol] name attribute name (属性の名前) # @param [String] value attribute value (属性の値) # @return [Meteor::Element] element (要素) # def []=(name, value) if !value.nil? @parser.attr(self, name, value) else @parser.remove_attr(self, name) end 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 flash @parser.flash end alias flush flash # # @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 (パターン).
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 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 |
# File 'lib/meteor/element.rb', line 39 class Element attr_accessor :name, :attributes, :mixed_content, :raw_content, :pattern, :document_sync, :normal, :cx, :non_nest, :parser, :type_value, :usable, :origin, :copy, :removed alias tag name alias tag= name= alias empty normal alias empty= normal= alias mono non_nest alias mono= non_nest= # # initializer (イニシャライザ) # @overload initialize(name) # @param [String,Symbol] name 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 Meteor::ONE if args[0].is_a?(String) initialize_s(args[0]) elsif args[0].is_a?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when Meteor::TWO initialize_two(args[0], args[1]) when Meteor::ZERO else raise ArgumentError end end # # initializer (イニシャライザ) # @param [String] name tag name (タグ名) # def initialize_s(name) @name = name # @attributes = nil # @mixed_content = nil # @pattern = nil # @document = nil # @parser=nil # @normal = false # @cx = false # @non_nest = false # @parent = false @usable = true end private :initialize_s # # initializer (イニシャライザ) # @param [Meteor::Element] elm element (要素) # def initialize_e(elm) initialize_two(elm, elm.parser) @usable = true end private :initialize_e def initialize_two(elm, ps) @parser = ps if normal ps.element(elm) else @name = elm.name @attributes = String.new(elm.attributes) @mixed_content = String.new(elm.mixed_content) # @pattern = String.new(elm.pattern) @pattern = elm.pattern @document = String.new(elm.document) @normal = elm.normal @cx = elm.cx @non_nest = elm.non_nest @origin = elm # @usable = false elm.copy = self end end private :initialize_two # # clone (複製する) # @overload clone() # @return [Meteor::Element] element (要素) # @overload clone(ps) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def clone(*args) case args.length when Meteor::ZERO clone_zero when Meteor::ONE clone_one(args[0]) end end # # clone (複製する) # @return [Meteor::Element] element (要素) # def clone_zero obj = parser.element_cache[object_id] if obj obj.attributes = String.new(attributes) obj.mixed_content = String.new(mixed_content) # obj.pattern = String.new(self.pattern) obj.document = String.new(document) obj.usable = true else obj = self.class.new(self) parser.element_cache[object_id] = obj end obj end private :clone_zero # # clone (複製する) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def clone_one(ps) obj = ps.element_hook if obj obj.attributes = String.new(attributes) obj.mixed_content = String.new(mixed_content) # obj.pattern = String.new(self.pattern) obj.document = String.new(document) else obj = self.class.new(self, ps) ps.element_hook = obj end obj end private :clone_one # # 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::HTML4 if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '>' # @document = "<#{@name}#{@attributes}>" end when Parser::XHTML, Parser::XHTML4, Parser::XML if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '/>' # @document = "<#{@name}#{@attributes}/>" end end else @document end end # # get element (要素を取得する) # @overload element() # get element (要素を取得する) # @return [Meteor::Element] element (要素) # @overload element(name) # get element using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] name tag name (タグ名) # @return [Meteor::Element] element (要素) # @overload element(name,attrs) # get element using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name,attr_value) # get element using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name1,attr_value1,attr_name2,attr_value2) # get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name) # get elements using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] name tag name (タグ名) # @return [Array<Meteor::Element>] element array(要素配列) # @overload elements(name,attrs) # get elements using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name,attr_value) # get elements using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name1,attr_value1,attr_name2,attr_value2) # get elements using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,id) # get cx(comment extension) tag using tag name and id attribute (タグ名とID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String,Symbol] name 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 alias text content # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def content=(value) @parser.content(self, value) end alias text= content= # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def unsafe_content=(value) @parser.content(self, value, false) end alias unsafe_text= unsafe_content= # # set attribute (属性をセットする) # @param [String,Symbol] name attribute name (属性の名前) # @param [String] value attribute value (属性の値) # @return [Meteor::Element] element (要素) # def []=(name, value) if !value.nil? @parser.attr(self, name, value) else @parser.remove_attr(self, name) end 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 flash @parser.flash end alias flush flash # # @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 (内容のエンティティ参照フラグ).
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 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 |
# File 'lib/meteor/element.rb', line 39 class Element attr_accessor :name, :attributes, :mixed_content, :raw_content, :pattern, :document_sync, :normal, :cx, :non_nest, :parser, :type_value, :usable, :origin, :copy, :removed alias tag name alias tag= name= alias empty normal alias empty= normal= alias mono non_nest alias mono= non_nest= # # initializer (イニシャライザ) # @overload initialize(name) # @param [String,Symbol] name 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 Meteor::ONE if args[0].is_a?(String) initialize_s(args[0]) elsif args[0].is_a?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when Meteor::TWO initialize_two(args[0], args[1]) when Meteor::ZERO else raise ArgumentError end end # # initializer (イニシャライザ) # @param [String] name tag name (タグ名) # def initialize_s(name) @name = name # @attributes = nil # @mixed_content = nil # @pattern = nil # @document = nil # @parser=nil # @normal = false # @cx = false # @non_nest = false # @parent = false @usable = true end private :initialize_s # # initializer (イニシャライザ) # @param [Meteor::Element] elm element (要素) # def initialize_e(elm) initialize_two(elm, elm.parser) @usable = true end private :initialize_e def initialize_two(elm, ps) @parser = ps if normal ps.element(elm) else @name = elm.name @attributes = String.new(elm.attributes) @mixed_content = String.new(elm.mixed_content) # @pattern = String.new(elm.pattern) @pattern = elm.pattern @document = String.new(elm.document) @normal = elm.normal @cx = elm.cx @non_nest = elm.non_nest @origin = elm # @usable = false elm.copy = self end end private :initialize_two # # clone (複製する) # @overload clone() # @return [Meteor::Element] element (要素) # @overload clone(ps) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def clone(*args) case args.length when Meteor::ZERO clone_zero when Meteor::ONE clone_one(args[0]) end end # # clone (複製する) # @return [Meteor::Element] element (要素) # def clone_zero obj = parser.element_cache[object_id] if obj obj.attributes = String.new(attributes) obj.mixed_content = String.new(mixed_content) # obj.pattern = String.new(self.pattern) obj.document = String.new(document) obj.usable = true else obj = self.class.new(self) parser.element_cache[object_id] = obj end obj end private :clone_zero # # clone (複製する) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def clone_one(ps) obj = ps.element_hook if obj obj.attributes = String.new(attributes) obj.mixed_content = String.new(mixed_content) # obj.pattern = String.new(self.pattern) obj.document = String.new(document) else obj = self.class.new(self, ps) ps.element_hook = obj end obj end private :clone_one # # 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::HTML4 if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '>' # @document = "<#{@name}#{@attributes}>" end when Parser::XHTML, Parser::XHTML4, Parser::XML if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '/>' # @document = "<#{@name}#{@attributes}/>" end end else @document end end # # get element (要素を取得する) # @overload element() # get element (要素を取得する) # @return [Meteor::Element] element (要素) # @overload element(name) # get element using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] name tag name (タグ名) # @return [Meteor::Element] element (要素) # @overload element(name,attrs) # get element using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name,attr_value) # get element using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name1,attr_value1,attr_name2,attr_value2) # get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name) # get elements using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] name tag name (タグ名) # @return [Array<Meteor::Element>] element array(要素配列) # @overload elements(name,attrs) # get elements using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name,attr_value) # get elements using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name1,attr_value1,attr_name2,attr_value2) # get elements using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,id) # get cx(comment extension) tag using tag name and id attribute (タグ名とID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String,Symbol] name 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 alias text content # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def content=(value) @parser.content(self, value) end alias text= content= # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def unsafe_content=(value) @parser.content(self, value, false) end alias unsafe_text= unsafe_content= # # set attribute (属性をセットする) # @param [String,Symbol] name attribute name (属性の名前) # @param [String] value attribute value (属性の値) # @return [Meteor::Element] element (要素) # def []=(name, value) if !value.nil? @parser.attr(self, name, value) else @parser.remove_attr(self, name) end 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 flash @parser.flash end alias flush flash # # @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 deletion flag (削除フラグ).
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 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 |
# File 'lib/meteor/element.rb', line 39 class Element attr_accessor :name, :attributes, :mixed_content, :raw_content, :pattern, :document_sync, :normal, :cx, :non_nest, :parser, :type_value, :usable, :origin, :copy, :removed alias tag name alias tag= name= alias empty normal alias empty= normal= alias mono non_nest alias mono= non_nest= # # initializer (イニシャライザ) # @overload initialize(name) # @param [String,Symbol] name 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 Meteor::ONE if args[0].is_a?(String) initialize_s(args[0]) elsif args[0].is_a?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when Meteor::TWO initialize_two(args[0], args[1]) when Meteor::ZERO else raise ArgumentError end end # # initializer (イニシャライザ) # @param [String] name tag name (タグ名) # def initialize_s(name) @name = name # @attributes = nil # @mixed_content = nil # @pattern = nil # @document = nil # @parser=nil # @normal = false # @cx = false # @non_nest = false # @parent = false @usable = true end private :initialize_s # # initializer (イニシャライザ) # @param [Meteor::Element] elm element (要素) # def initialize_e(elm) initialize_two(elm, elm.parser) @usable = true end private :initialize_e def initialize_two(elm, ps) @parser = ps if normal ps.element(elm) else @name = elm.name @attributes = String.new(elm.attributes) @mixed_content = String.new(elm.mixed_content) # @pattern = String.new(elm.pattern) @pattern = elm.pattern @document = String.new(elm.document) @normal = elm.normal @cx = elm.cx @non_nest = elm.non_nest @origin = elm # @usable = false elm.copy = self end end private :initialize_two # # clone (複製する) # @overload clone() # @return [Meteor::Element] element (要素) # @overload clone(ps) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def clone(*args) case args.length when Meteor::ZERO clone_zero when Meteor::ONE clone_one(args[0]) end end # # clone (複製する) # @return [Meteor::Element] element (要素) # def clone_zero obj = parser.element_cache[object_id] if obj obj.attributes = String.new(attributes) obj.mixed_content = String.new(mixed_content) # obj.pattern = String.new(self.pattern) obj.document = String.new(document) obj.usable = true else obj = self.class.new(self) parser.element_cache[object_id] = obj end obj end private :clone_zero # # clone (複製する) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def clone_one(ps) obj = ps.element_hook if obj obj.attributes = String.new(attributes) obj.mixed_content = String.new(mixed_content) # obj.pattern = String.new(self.pattern) obj.document = String.new(document) else obj = self.class.new(self, ps) ps.element_hook = obj end obj end private :clone_one # # 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::HTML4 if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '>' # @document = "<#{@name}#{@attributes}>" end when Parser::XHTML, Parser::XHTML4, Parser::XML if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '/>' # @document = "<#{@name}#{@attributes}/>" end end else @document end end # # get element (要素を取得する) # @overload element() # get element (要素を取得する) # @return [Meteor::Element] element (要素) # @overload element(name) # get element using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] name tag name (タグ名) # @return [Meteor::Element] element (要素) # @overload element(name,attrs) # get element using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name,attr_value) # get element using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name1,attr_value1,attr_name2,attr_value2) # get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name) # get elements using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] name tag name (タグ名) # @return [Array<Meteor::Element>] element array(要素配列) # @overload elements(name,attrs) # get elements using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name,attr_value) # get elements using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name1,attr_value1,attr_name2,attr_value2) # get elements using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,id) # get cx(comment extension) tag using tag name and id attribute (タグ名とID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String,Symbol] name 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 alias text content # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def content=(value) @parser.content(self, value) end alias text= content= # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def unsafe_content=(value) @parser.content(self, value, false) end alias unsafe_text= unsafe_content= # # set attribute (属性をセットする) # @param [String,Symbol] name attribute name (属性の名前) # @param [String] value attribute value (属性の値) # @return [Meteor::Element] element (要素) # def []=(name, value) if !value.nil? @parser.attr(self, name, value) else @parser.remove_attr(self, name) end 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 flash @parser.flash end alias flush flash # # @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 |
#type_value ⇒ String
Returns type (タイプ属性).
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 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 |
# File 'lib/meteor/element.rb', line 39 class Element attr_accessor :name, :attributes, :mixed_content, :raw_content, :pattern, :document_sync, :normal, :cx, :non_nest, :parser, :type_value, :usable, :origin, :copy, :removed alias tag name alias tag= name= alias empty normal alias empty= normal= alias mono non_nest alias mono= non_nest= # # initializer (イニシャライザ) # @overload initialize(name) # @param [String,Symbol] name 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 Meteor::ONE if args[0].is_a?(String) initialize_s(args[0]) elsif args[0].is_a?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when Meteor::TWO initialize_two(args[0], args[1]) when Meteor::ZERO else raise ArgumentError end end # # initializer (イニシャライザ) # @param [String] name tag name (タグ名) # def initialize_s(name) @name = name # @attributes = nil # @mixed_content = nil # @pattern = nil # @document = nil # @parser=nil # @normal = false # @cx = false # @non_nest = false # @parent = false @usable = true end private :initialize_s # # initializer (イニシャライザ) # @param [Meteor::Element] elm element (要素) # def initialize_e(elm) initialize_two(elm, elm.parser) @usable = true end private :initialize_e def initialize_two(elm, ps) @parser = ps if normal ps.element(elm) else @name = elm.name @attributes = String.new(elm.attributes) @mixed_content = String.new(elm.mixed_content) # @pattern = String.new(elm.pattern) @pattern = elm.pattern @document = String.new(elm.document) @normal = elm.normal @cx = elm.cx @non_nest = elm.non_nest @origin = elm # @usable = false elm.copy = self end end private :initialize_two # # clone (複製する) # @overload clone() # @return [Meteor::Element] element (要素) # @overload clone(ps) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def clone(*args) case args.length when Meteor::ZERO clone_zero when Meteor::ONE clone_one(args[0]) end end # # clone (複製する) # @return [Meteor::Element] element (要素) # def clone_zero obj = parser.element_cache[object_id] if obj obj.attributes = String.new(attributes) obj.mixed_content = String.new(mixed_content) # obj.pattern = String.new(self.pattern) obj.document = String.new(document) obj.usable = true else obj = self.class.new(self) parser.element_cache[object_id] = obj end obj end private :clone_zero # # clone (複製する) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def clone_one(ps) obj = ps.element_hook if obj obj.attributes = String.new(attributes) obj.mixed_content = String.new(mixed_content) # obj.pattern = String.new(self.pattern) obj.document = String.new(document) else obj = self.class.new(self, ps) ps.element_hook = obj end obj end private :clone_one # # 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::HTML4 if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '>' # @document = "<#{@name}#{@attributes}>" end when Parser::XHTML, Parser::XHTML4, Parser::XML if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '/>' # @document = "<#{@name}#{@attributes}/>" end end else @document end end # # get element (要素を取得する) # @overload element() # get element (要素を取得する) # @return [Meteor::Element] element (要素) # @overload element(name) # get element using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] name tag name (タグ名) # @return [Meteor::Element] element (要素) # @overload element(name,attrs) # get element using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name,attr_value) # get element using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name1,attr_value1,attr_name2,attr_value2) # get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name) # get elements using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] name tag name (タグ名) # @return [Array<Meteor::Element>] element array(要素配列) # @overload elements(name,attrs) # get elements using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name,attr_value) # get elements using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name1,attr_value1,attr_name2,attr_value2) # get elements using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,id) # get cx(comment extension) tag using tag name and id attribute (タグ名とID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String,Symbol] name 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 alias text content # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def content=(value) @parser.content(self, value) end alias text= content= # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def unsafe_content=(value) @parser.content(self, value, false) end alias unsafe_text= unsafe_content= # # set attribute (属性をセットする) # @param [String,Symbol] name attribute name (属性の名前) # @param [String] value attribute value (属性の値) # @return [Meteor::Element] element (要素) # def []=(name, value) if !value.nil? @parser.attr(self, name, value) else @parser.remove_attr(self, name) end 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 flash @parser.flash end alias flush flash # # @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 (有効・無効フラグ).
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 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 |
# File 'lib/meteor/element.rb', line 39 class Element attr_accessor :name, :attributes, :mixed_content, :raw_content, :pattern, :document_sync, :normal, :cx, :non_nest, :parser, :type_value, :usable, :origin, :copy, :removed alias tag name alias tag= name= alias empty normal alias empty= normal= alias mono non_nest alias mono= non_nest= # # initializer (イニシャライザ) # @overload initialize(name) # @param [String,Symbol] name 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 Meteor::ONE if args[0].is_a?(String) initialize_s(args[0]) elsif args[0].is_a?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when Meteor::TWO initialize_two(args[0], args[1]) when Meteor::ZERO else raise ArgumentError end end # # initializer (イニシャライザ) # @param [String] name tag name (タグ名) # def initialize_s(name) @name = name # @attributes = nil # @mixed_content = nil # @pattern = nil # @document = nil # @parser=nil # @normal = false # @cx = false # @non_nest = false # @parent = false @usable = true end private :initialize_s # # initializer (イニシャライザ) # @param [Meteor::Element] elm element (要素) # def initialize_e(elm) initialize_two(elm, elm.parser) @usable = true end private :initialize_e def initialize_two(elm, ps) @parser = ps if normal ps.element(elm) else @name = elm.name @attributes = String.new(elm.attributes) @mixed_content = String.new(elm.mixed_content) # @pattern = String.new(elm.pattern) @pattern = elm.pattern @document = String.new(elm.document) @normal = elm.normal @cx = elm.cx @non_nest = elm.non_nest @origin = elm # @usable = false elm.copy = self end end private :initialize_two # # clone (複製する) # @overload clone() # @return [Meteor::Element] element (要素) # @overload clone(ps) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def clone(*args) case args.length when Meteor::ZERO clone_zero when Meteor::ONE clone_one(args[0]) end end # # clone (複製する) # @return [Meteor::Element] element (要素) # def clone_zero obj = parser.element_cache[object_id] if obj obj.attributes = String.new(attributes) obj.mixed_content = String.new(mixed_content) # obj.pattern = String.new(self.pattern) obj.document = String.new(document) obj.usable = true else obj = self.class.new(self) parser.element_cache[object_id] = obj end obj end private :clone_zero # # clone (複製する) # @param [Meteor::Parser] ps parser (パーサ) # @return [Meteor::Element] element (要素) # def clone_one(ps) obj = ps.element_hook if obj obj.attributes = String.new(attributes) obj.mixed_content = String.new(mixed_content) # obj.pattern = String.new(self.pattern) obj.document = String.new(document) else obj = self.class.new(self, ps) ps.element_hook = obj end obj end private :clone_one # # 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::HTML4 if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '>' # @document = "<#{@name}#{@attributes}>" end when Parser::XHTML, Parser::XHTML4, Parser::XML if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '/>' # @document = "<#{@name}#{@attributes}/>" end end else @document end end # # get element (要素を取得する) # @overload element() # get element (要素を取得する) # @return [Meteor::Element] element (要素) # @overload element(name) # get element using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] name tag name (タグ名) # @return [Meteor::Element] element (要素) # @overload element(name,attrs) # get element using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name,attr_value) # get element using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name1,attr_value1,attr_name2,attr_value2) # get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name) # get elements using tag name (要素のタグ名で要素を取得する) # @param [String,Symbol] name tag name (タグ名) # @return [Array<Meteor::Element>] element array(要素配列) # @overload elements(name,attrs) # get elements using tag name and attribute map (要素のタグ名と属性(属性名="属性値")あるいは属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name,attr_value) # get elements using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,attr_name1,attr_value1,attr_name2,attr_value2) # get elements using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で要素を取得する) # @param [String,Symbol] name 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(name,id) # get cx(comment extension) tag using tag name and id attribute (タグ名とID属性(id="ID属性値")でCX(コメント拡張)タグを取得する) # @param [String,Symbol] name 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 alias text content # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def content=(value) @parser.content(self, value) end alias text= content= # # set content of element (要素の内容をセットする) # @param [String] value content (要素の内容) # @return [Meteor::Element] element (要素) # def unsafe_content=(value) @parser.content(self, value, false) end alias unsafe_text= unsafe_content= # # set attribute (属性をセットする) # @param [String,Symbol] name attribute name (属性の名前) # @param [String] value attribute value (属性の値) # @return [Meteor::Element] element (要素) # def []=(name, value) if !value.nil? @parser.attr(self, name, value) else @parser.remove_attr(self, name) end 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 flash @parser.flash end alias flush flash # # @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 |
Instance Method Details
#[](name) ⇒ String
get attribute value (属性の値を取得する)
503 504 505 |
# File 'lib/meteor/element.rb', line 503 def [](name) @parser.attr(self, name) end |
#[]=(name, value) ⇒ Meteor::Element
set attribute (属性をセットする)
490 491 492 493 494 495 496 |
# File 'lib/meteor/element.rb', line 490 def []=(name, value) if !value.nil? @parser.attr(self, name, value) else @parser.remove_attr(self, name) end end |
#attr(attr) ⇒ Meteor::Element #attr(attr_name, attr_value) ⇒ Meteor::Element #attr(attr_name) ⇒ String
388 389 390 |
# File 'lib/meteor/element.rb', line 388 def attr(attrs, *args) @parser.attr(self, attrs, *args) end |
#attr=(attr) ⇒ Meteor::Element
set attribute of element (要素の属性をセットする)
397 398 399 |
# File 'lib/meteor/element.rb', line 397 def attr=(attr) @parser.attr(self, attr) end |
#attr_map(attr_map) ⇒ Meteor::Element #attr_map ⇒ Meteor::AttributeMap
427 428 429 |
# File 'lib/meteor/element.rb', line 427 def attr_map(*args) @parser.attr_map(self, *args) end |
#attr_map=(attr_map) ⇒ Meteor::Element
set attribute map (属性マップをセットする)
436 437 438 |
# File 'lib/meteor/element.rb', line 436 def attr_map=(attr_map) @parser.attr_map(self, attr_map) end |
#attrs ⇒ Hash<String,String>, Hash<Symbol,String>
get attribute map (属性マップを取得する)
413 414 415 |
# File 'lib/meteor/element.rb', line 413 def attrs @parser.attrs(self) end |
#attrs=(attrs) ⇒ Meteor::Element
set attribute map (要素マップをセットする)
405 406 407 |
# File 'lib/meteor/element.rb', line 405 def attrs=(attrs) @parser.attrs(self, attrs) end |
#clone ⇒ Meteor::Element #clone(ps) ⇒ Meteor::Element
clone (複製する)
141 142 143 144 145 146 147 148 |
# File 'lib/meteor/element.rb', line 141 def clone(*args) case args.length when Meteor::ZERO clone_zero when Meteor::ONE clone_one(args[0]) end end |
#content(content, entity_ref = true) ⇒ Meteor::Element #content(content) ⇒ Meteor::Element #content ⇒ String Also known as: text
456 457 458 |
# File 'lib/meteor/element.rb', line 456 def content(*args) @parser.content(self, *args) end |
#content=(value) ⇒ Meteor::Element Also known as: text=
set content of element (要素の内容をセットする)
467 468 469 |
# File 'lib/meteor/element.rb', line 467 def content=(value) @parser.content(self, value) end |
#cxtag(name, id) ⇒ Meteor::Element #cxtag(id) ⇒ Meteor::Element
get cx(comment extension) tag (CX(コメント拡張)タグを取得する)
368 369 370 |
# File 'lib/meteor/element.rb', line 368 def cxtag(*args) @parser.cxtag(*args) end |
#document ⇒ String
get document (ドキュメントを取得する)
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 |
# File 'lib/meteor/element.rb', line 205 def document if @document_sync @document_sync = false case @parser.doc_type when Parser::HTML, Parser::HTML4 if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '>' # @document = "<#{@name}#{@attributes}>" end when Parser::XHTML, Parser::XHTML4, Parser::XML if @cx # @pattern_cc = String.new('') << '<!-- @' << elm.name << ' ' << elm.attributes << '-->' << elm.mixed_content << '<!-- /@' << elm.name << ' -->' @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" elsif @normal # @pattern_cc = String.new('') << "<" << elm.name << elm.attributes << '>' << elm.mixed_content << '</' << elm.name << '>' @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = String.new('') << '<' << @name << @attributes << '/>' # @document = "<#{@name}#{@attributes}/>" end end else @document end end |
#document=(doc) ⇒ Object
set document (ドキュメントをセットする)
196 197 198 199 |
# File 'lib/meteor/element.rb', line 196 def document=(doc) @document_sync = false @document = doc end |
#element ⇒ Meteor::Element #element(name) ⇒ Meteor::Element #element(name, attrs) ⇒ Meteor::Element #element(attrs) ⇒ Meteor::Element #element(name, attr_name, attr_value) ⇒ Meteor::Element #element(attr_name, attr_value) ⇒ Meteor::Element #element(name, 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 (要素を取得する)
286 287 288 289 290 291 292 293 294 |
# File 'lib/meteor/element.rb', line 286 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(name) ⇒ Array<Meteor::Element> #elements(name, attrs) ⇒ Array<Meteor::Element> #elements(attrs) ⇒ Array<Meteor::Element> #elements(name, attr_name, attr_value) ⇒ Array<Meteor::Element> #elements(attr_name, attr_value) ⇒ Array<Meteor::Element> #elements(name, 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 (要素を取得する)
340 341 342 |
# File 'lib/meteor/element.rb', line 340 def elements(*args) @parser.elements(*args) end |
#execute(hook) ⇒ Object #execute(loop, list) ⇒ Object
541 542 543 |
# File 'lib/meteor/element.rb', line 541 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セレクタの部分的サポート)
350 351 352 |
# File 'lib/meteor/element.rb', line 350 def find(selector) @parser.find(selector) end |
#flash ⇒ Object Also known as: flush
reflect (反映する)
526 527 528 |
# File 'lib/meteor/element.rb', line 526 def flash @parser.flash end |
#remove ⇒ Object
remove element (要素を削除する)
519 520 521 |
# File 'lib/meteor/element.rb', line 519 def remove @parser.remove_element(self) end |
#remove_attr(attr_name) ⇒ Meteor::Element
remove attribute of element (要素の属性を消す)
512 513 514 |
# File 'lib/meteor/element.rb', line 512 def remove_attr(attr_name) @parser.remove_attr(self, attr_name) end |
#unsafe_content=(value) ⇒ Meteor::Element Also known as: unsafe_text=
set content of element (要素の内容をセットする)
478 479 480 |
# File 'lib/meteor/element.rb', line 478 def unsafe_content=(value) @parser.content(self, value, false) end |