Class: Meteor::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/meteor.rb

Overview

要素クラス

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Element #initialize(elm) ⇒ Element

イニシャライザ

Overloads:

Parameters:

  • args (Array)

    引数配列



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

#attributesObject

String

属性群



141
142
143
# File 'lib/meteor.rb', line 141

def attributes
  @attributes
end

#copyObject

Meteor::Element

複製ポインタ



153
154
155
# File 'lib/meteor.rb', line 153

def copy
  @copy
end

#cxObject

true,false

コメント拡張タグフラグ



146
147
148
# File 'lib/meteor.rb', line 146

def cx
  @cx
end

#document_syncObject

true,false

ドキュメント更新フラグ



144
145
146
# File 'lib/meteor.rb', line 144

def document_sync
  @document_sync
end

#emptyObject

true,false

内容存在フラグ



145
146
147
# File 'lib/meteor.rb', line 145

def empty
  @empty
end

#mixed_contentObject

String

内容



142
143
144
# File 'lib/meteor.rb', line 142

def mixed_content
  @mixed_content
end

#monoObject

true,false

子要素存在フラグ



147
148
149
# File 'lib/meteor.rb', line 147

def mono
  @mono
end

#nameObject

String

要素名



140
141
142
# File 'lib/meteor.rb', line 140

def name
  @name
end

#originObject

Meteor::Element

原本ポインタ



152
153
154
# File 'lib/meteor.rb', line 152

def origin
  @origin
end

#parserObject

Meteor::Parser

パーサ



148
149
150
# File 'lib/meteor.rb', line 148

def parser
  @parser
end

#patternObject

String

パターン



143
144
145
# File 'lib/meteor.rb', line 143

def pattern
  @pattern
end

#type_valueObject

String

タイプ属性



149
150
151
# File 'lib/meteor.rb', line 149

def type_value
  @type_value
end

#usableObject

attr_accessor :arguments #パターン変更用属性マップ



151
152
153
# File 'lib/meteor.rb', line 151

def usable
  @usable
end

Class Method Details

.new!(*args) ⇒ Object

コピーを作成する

Parameters:

  • args (Array)

    引数配列



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

属性の値を取得する

Parameters:

  • name (String)

    属性の名前

Returns:

  • (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

属性をセットする

Parameters:

  • name (String)

    属性の名前

  • value (String)

    属性の値

Returns:



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

Overloads:

  • #attribute(attr_name, attr_value) ⇒ Meteor::Element

    要素の属性をセットする

    Parameters:

    • attr_name (String)

      属性名

    • attr_value (String, true, false)

      属性値

    Returns:

  • #attribute(attr_name) ⇒ String

    要素の属性値を取得する

    Parameters:

    • attr_name (String)

      属性名

    Returns:

    • (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_mapMeteor::AttributeMap

Overloads:



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

子要素を取得する

Overloads:

  • #child(elm_name) ⇒ Meteor::Element

    Returns 要素.

    Parameters:

    • elm_name (String)

      要素名

    Returns:

  • #child(elm_name, attr_name, attr_value) ⇒ Meteor::Element

    Returns 要素.

    Parameters:

    • elm_name (String)

      要素名

    • attr_name (String)

      属性名

    • attr_value (String)

      属性値

    Returns:

  • #child(attr_name, attr_value) ⇒ Meteor::Element

    Returns 要素.

    Parameters:

    • attr_name (String)

      属性名

    • attr_value (String)

      属性値

    Returns:

  • #child(elm_name, attr_name1, attr_value1, attr_name2, attr_value2) ⇒ Meteor::Element

    Returns 要素.

    Parameters:

    • elm_name (String)

      要素の名前

    • attr_name1 (String)

      属性名1

    • attr_value1 (String)

      属性値2

    • attr_name2 (String)

      属性名2

    • attr_value2 (String)

      属性値2

    Returns:

  • #child(attr_name1, attr_value1, attr_name2, attr_value2) ⇒ Meteor::Element

    Returns 要素.

    Parameters:

    • attr_name1 (String)

      属性名1

    • attr_value1 (String)

      属性値2

    • attr_name2 (String)

      属性名2

    • attr_value2 (String)

      属性値2

    Returns:



229
230
231
# File 'lib/meteor.rb', line 229

def child(*args)
  @parser.element(*args)
end

#cloneObject

複製する



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 #contentString

Overloads:

  • #content(content, entity_ref = true) ⇒ Meteor::Element

    要素の内容をセットする

    Parameters:

    • content (String)

      要素の内容

    • entity_ref (true, false) (defaults to: true)

      エンティティ参照フラグ

    Returns:

  • #content(content) ⇒ Meteor::Element

    要素の内容をセットする

    Parameters:

    • content (String)

      要素の内容

    Returns:

  • #contentString

    要素の内容を取得する

    Returns:

    • (String)

      内容



289
290
291
# File 'lib/meteor.rb', line 289

def content(*args)
  @parser.content(self,*args)
end

#content=(value) ⇒ Meteor::Element

内容をセットする

Parameters:

  • value (String)

    内容

Returns:



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(コメント拡張)タグを取得する

Overloads:



243
244
245
# File 'lib/meteor.rb', line 243

def cxtag(*args)
  @parser.cxtag(*args)
end

#documentObject

ドキュメントを取得する



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

ドキュメントをセットする

Parameters:

  • doc (String)

    ドキュメント



344
345
346
347
# File 'lib/meteor.rb', line 344

def document=(doc)
  @document_sync = false
  @document = doc
end

#execute(*args) ⇒ Object

フッククラスの処理を実行する

Parameters:

  • args (Array)

    引数配列



404
405
406
# File 'lib/meteor.rb', line 404

def execute(*args)
  @parser.execute(self,*args)
end

#flushObject

反映する



396
397
398
# File 'lib/meteor.rb', line 396

def flush
  @parser.flush
end

#removeObject

要素を削除する



389
390
391
# File 'lib/meteor.rb', line 389

def remove
  @parser.remove_element(self)
end

#remove_attribute(attr_name) ⇒ Meteor::Element

要素の属性を消す

Parameters:

  • attr_name (String)

    属性名

Returns:



336
337
338
# File 'lib/meteor.rb', line 336

def remove_attribute(attr_name)
  @parser.remove_attribute(self,attr_name)
end