Class: Meteor::Element
- Inherits:
-
Object
- Object
- Meteor::Element
- Defined in:
- lib/meteor.rb
Overview
要素クラス
Instance Attribute Summary collapse
-
#attributes ⇒ Object
- String
-
属性群.
-
#copy ⇒ Object
- Meteor::Element
-
複製ポインタ.
-
#cx ⇒ Object
- true,false
-
コメント拡張タグフラグ.
-
#document_sync ⇒ Object
- true,false
-
ドキュメント更新フラグ.
-
#empty ⇒ Object
- true,false
-
内容存在フラグ.
-
#mixed_content ⇒ Object
- String
-
内容.
-
#mono ⇒ Object
- true,false
-
子要素存在フラグ.
-
#name ⇒ Object
- String
-
要素名.
-
#origin ⇒ Object
- Meteor::Element
-
原本ポインタ.
-
#parser ⇒ Object
- Meteor::Parser
-
パーサ.
-
#pattern ⇒ Object
- String
-
パターン.
-
#type_value ⇒ Object
- String
-
タイプ属性.
-
#usable ⇒ Object
attr_accessor :arguments #パターン変更用属性マップ.
Class Method Summary collapse
-
.new!(*args) ⇒ Object
コピーを作成する.
Instance Method Summary collapse
-
#[](name) ⇒ String
属性の値を取得する.
-
#[]=(name, value) ⇒ Meteor::Element
属性をセットする.
- #attribute(*args) ⇒ Object
- #attribute_map(*args) ⇒ Object
-
#child(*args) ⇒ Object
子要素を取得する.
-
#clone ⇒ Object
複製する.
- #content(*args) ⇒ Object
-
#content=(value) ⇒ Meteor::Element
内容をセットする.
-
#cxtag(*args) ⇒ Object
CX(コメント拡張)タグを取得する.
-
#document ⇒ Object
ドキュメントを取得する.
-
#document=(doc) ⇒ Object
ドキュメントをセットする.
-
#execute(*args) ⇒ Object
フッククラスの処理を実行する.
-
#flush ⇒ Object
反映する.
-
#initialize(*args) ⇒ Element
constructor
イニシャライザ.
-
#remove ⇒ Object
要素を削除する.
-
#remove_attribute(attr_name) ⇒ Meteor::Element
要素の属性を消す.
Constructor Details
#initialize(name) ⇒ Element #initialize(elm) ⇒ Element
イニシャライザ
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 |
# File 'lib/meteor.rb', line 58 def initialize(*args) case args.length when ONE if args[0].kind_of?(String) then initialize_s(args[0]) elsif args[0].kind_of?(Meteor::Element) initialize_e(args[0]) else raise ArgumentError end when TWO @name = args[0].name @attributes = String.new(args[0].attributes) @mixed_content = String.new(args[0].mixed_content) #@pattern = String.new(args[0].pattern) @pattern = args[0].pattern @document = String.new(args[0].document) @empty = args[0].empty @cx = args[0].cx @mono = args[0].mono @parser = args[1] #@arguments = AttributeMap.new(args[0].arguments) #@usable = false @origin = args[0] args[0].copy = self else raise ArgumentError end end |
Instance Attribute Details
#attributes ⇒ Object
- String
-
属性群
141 142 143 |
# File 'lib/meteor.rb', line 141 def attributes @attributes end |
#copy ⇒ Object
- Meteor::Element
-
複製ポインタ
153 154 155 |
# File 'lib/meteor.rb', line 153 def copy @copy end |
#cx ⇒ Object
- true,false
-
コメント拡張タグフラグ
146 147 148 |
# File 'lib/meteor.rb', line 146 def cx @cx end |
#document_sync ⇒ Object
- true,false
-
ドキュメント更新フラグ
144 145 146 |
# File 'lib/meteor.rb', line 144 def document_sync @document_sync end |
#empty ⇒ Object
- true,false
-
内容存在フラグ
145 146 147 |
# File 'lib/meteor.rb', line 145 def empty @empty end |
#mixed_content ⇒ Object
- String
-
内容
142 143 144 |
# File 'lib/meteor.rb', line 142 def mixed_content @mixed_content end |
#mono ⇒ Object
- true,false
-
子要素存在フラグ
147 148 149 |
# File 'lib/meteor.rb', line 147 def mono @mono end |
#name ⇒ Object
- String
-
要素名
140 141 142 |
# File 'lib/meteor.rb', line 140 def name @name end |
#origin ⇒ Object
- Meteor::Element
-
原本ポインタ
152 153 154 |
# File 'lib/meteor.rb', line 152 def origin @origin end |
#parser ⇒ Object
- Meteor::Parser
-
パーサ
148 149 150 |
# File 'lib/meteor.rb', line 148 def parser @parser end |
#pattern ⇒ Object
- String
-
パターン
143 144 145 |
# File 'lib/meteor.rb', line 143 def pattern @pattern end |
#type_value ⇒ Object
- String
-
タイプ属性
149 150 151 |
# File 'lib/meteor.rb', line 149 def type_value @type_value end |
#usable ⇒ Object
attr_accessor :arguments #パターン変更用属性マップ
151 152 153 |
# File 'lib/meteor.rb', line 151 def usable @usable end |
Class Method Details
.new!(*args) ⇒ Object
コピーを作成する
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/meteor.rb', line 159 def self.new!(*args) case args.length #when ONE # #self.new_1!(args[0]) # args[0].clone when TWO @obj = args[1].root_element.element if @obj then @obj.attributes = String.new(args[0].attributes) @obj.mixed_content = String.new(args[0].mixed_content) #@obj.pattern = String.new(args[0].pattern) @obj.document = String.new(args[0].document) #@obj.arguments = AttributeMap.new(args[0].arguments) @obj else @obj = self.new(args[0],args[1]) args[1].root_element.element = @obj @obj end end end |
Instance Method Details
#[](name) ⇒ String
属性の値を取得する
322 323 324 325 326 327 328 329 |
# File 'lib/meteor.rb', line 322 def [](name) ##if !name.kind_of?(String) || CONTENT_STR != name then #if CONTENT_STR != name then @parser.attribute(self,name) #else # content() #end end |
#[]=(name, value) ⇒ Meteor::Element
属性をセットする
308 309 310 311 312 313 314 315 |
# File 'lib/meteor.rb', line 308 def []=(name,value) ##if !name.kind_of?(String) || CONTENT_STR != name then #if CONTENT_STR != name then @parser.attribute(self,name,value) #else # @parser.content(self,value) #end end |
#attribute(attr_name, attr_value) ⇒ Meteor::Element #attribute(attr_name) ⇒ String
258 259 260 |
# File 'lib/meteor.rb', line 258 def attribute(*args) @parser.attribute(self,*args) end |
#attribute_map(attr_map) ⇒ Meteor::Element #attribute_map ⇒ Meteor::AttributeMap
271 272 273 |
# File 'lib/meteor.rb', line 271 def attribute_map(*args) @parser.attribute_map(self,*args) end |
#child(elm_name) ⇒ Meteor::Element #child(elm_name, attr_name, attr_value) ⇒ Meteor::Element #child(attr_name, attr_value) ⇒ Meteor::Element #child(elm_name, attr_name1, attr_value1, attr_name2, attr_value2) ⇒ Meteor::Element #child(attr_name1, attr_value1, attr_name2, attr_value2) ⇒ Meteor::Element
子要素を取得する
229 230 231 |
# File 'lib/meteor.rb', line 229 def child(*args) @parser.element(*args) end |
#clone ⇒ Object
複製する
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/meteor.rb', line 184 def clone obj = self.parser.element_cache[self.object_id] if obj then obj.attributes = String.new(self.attributes) obj.mixed_content = String.new(self.mixed_content) #obj.pattern = String.new(self.pattern) obj.document = String.new(self.document) #obj.arguments = AttributeMap.new(self.arguments) obj.usable = true obj else obj = self.new(self) self.parser.element_cache[self.object_id] = obj obj end end |
#content(content, entity_ref = true) ⇒ Meteor::Element #content(content) ⇒ Meteor::Element #content ⇒ String
289 290 291 |
# File 'lib/meteor.rb', line 289 def content(*args) @parser.content(self,*args) end |
#content=(value) ⇒ Meteor::Element
内容をセットする
298 299 300 |
# File 'lib/meteor.rb', line 298 def content=(value) @parser.content(self,value) end |
#cxtag(elm_name, id) ⇒ Meteor::Element #cxtag(id) ⇒ Meteor::Element
CX(コメント拡張)タグを取得する
243 244 245 |
# File 'lib/meteor.rb', line 243 def cxtag(*args) @parser.cxtag(*args) end |
#document ⇒ Object
ドキュメントを取得する
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 |
# File 'lib/meteor.rb', line 352 def document if @document_sync then @document_sync = false case @parser.doc_type when Parser::HTML then if @cx then #@pattern_cc = '' << SET_CX_1 << elm.name << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.name << SET_CX_4 @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" else if @empty then #@pattern_cc = '' << TAG_OPEN << elm.name << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.name << TAG_CLOSE @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @name << @attributes << Meteor::Core::Kernel::TAG_CLOSE end end when Parser::XHTML,Parser::XML then if @cx then #@pattern_cc = '' << SET_CX_1 << elm.name << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.name << SET_CX_4 @document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->" else if @empty then #@pattern_cc = '' << TAG_OPEN << elm.name << elm.attributes << TAG_CLOSE << elm.mixed_content << TAG_OPEN3 << elm.name << TAG_CLOSE @document = "<#{@name}#{@attributes}>#{@mixed_content}</#{@name}>" else @document = '' << Meteor::Core::Kernel::TAG_OPEN << @name << @attributes << Meteor::Core::Kernel::TAG_CLOSE3 end end end else @document end end |
#document=(doc) ⇒ Object
ドキュメントをセットする
344 345 346 347 |
# File 'lib/meteor.rb', line 344 def document=(doc) @document_sync = false @document = doc end |
#execute(*args) ⇒ Object
フッククラスの処理を実行する
404 405 406 |
# File 'lib/meteor.rb', line 404 def execute(*args) @parser.execute(self,*args) end |
#flush ⇒ Object
反映する
396 397 398 |
# File 'lib/meteor.rb', line 396 def flush @parser.flush end |
#remove ⇒ Object
要素を削除する
389 390 391 |
# File 'lib/meteor.rb', line 389 def remove @parser.remove_element(self) end |
#remove_attribute(attr_name) ⇒ Meteor::Element
要素の属性を消す
336 337 338 |
# File 'lib/meteor.rb', line 336 def remove_attribute(attr_name) @parser.remove_attribute(self,attr_name) end |