Class: Meteor::Element

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

Overview

Element Class (要素クラス)

Direct Known Subclasses

RootElement

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Element) initialize(name) - (Element) initialize(elm) - (Element) initialize(elm, ps)

initializer (イニシャライザ)

Overloads:



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
# File 'lib/meteor.rb', line 60

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]
      #@usable = false
      @origin = args[0]
      args[0].copy = self
    else
      raise ArgumentError
  end
end

Instance Attribute Details

- (Object) attributes

String

attributes (属性群)



177
178
179
# File 'lib/meteor.rb', line 177

def attributes
  @attributes
end

- (Object) copy

Meteor::Element

copy pointer (複製ポインタ)



188
189
190
# File 'lib/meteor.rb', line 188

def copy
  @copy
end

- (Object) cx

true,false

comment extension tag flag (コメント拡張タグフラグ)



182
183
184
# File 'lib/meteor.rb', line 182

def cx
  @cx
end

- (Object) document_sync

true,false

document update flag (ドキュメント更新フラグ)



180
181
182
# File 'lib/meteor.rb', line 180

def document_sync
  @document_sync
end

- (Object) empty

true,false

content empty flag (内容存在フラグ)



181
182
183
# File 'lib/meteor.rb', line 181

def empty
  @empty
end

- (Object) mixed_content

String

content (内容)



178
179
180
# File 'lib/meteor.rb', line 178

def mixed_content
  @mixed_content
end

- (Object) mono

true,false

child element existance flag (子要素存在フラグ)



183
184
185
# File 'lib/meteor.rb', line 183

def mono
  @mono
end

- (Object) name

String

element name (要素名)



176
177
178
# File 'lib/meteor.rb', line 176

def name
  @name
end

- (Object) origin

true,false

usable flag (有効・無効フラグ)

Meteor::Element

original pointer (原本ポインタ)



187
188
189
# File 'lib/meteor.rb', line 187

def origin
  @origin
end

- (Object) parser

Meteor::Parser

parser(パーサ)



184
185
186
# File 'lib/meteor.rb', line 184

def parser
  @parser
end

- (Object) pattern

String

pattern (パターン)



179
180
181
# File 'lib/meteor.rb', line 179

def pattern
  @pattern
end

- (Object) removed

true,false

delete flag (削除フラグ)



189
190
191
# File 'lib/meteor.rb', line 189

def removed
  @removed
end

- (Object) type_value

String

タイプ属性



185
186
187
# File 'lib/meteor.rb', line 185

def type_value
  @type_value
end

- (Object) usable

Returns the value of attribute usable



186
187
188
# File 'lib/meteor.rb', line 186

def usable
  @usable
end

Class Method Details

+ (Meteor::Element) new!(elm, ps)

make copy (コピーを作成する)

Element (要素)

Parameters:

Returns:



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/meteor.rb', line 136

def self.new!(*args)
  case args.length
    when TWO
      @obj = args[1].element_hook
      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
      else
        @obj = self.new(args[0], args[1])
        args[1].element_hook = @obj
        @obj
      end
    else
      raise ArgumentError
  end
end

Instance Method Details

- (String) [](name)

属性の値を取得する

Parameters:

  • name (String)

    attribute name (属性の名前)

Returns:

  • (String)

    attribute value (属性の値)



398
399
400
# File 'lib/meteor.rb', line 398

def [](name)
  @parser.attr(self, name)
end

- (Meteor::Element) []=(name, value)

set attribute (属性をセットする)

Parameters:

  • name (String)

    attribute name (属性の名前)

  • value (String)

    attribute value (属性の値)

Returns:



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

def []=(name, value)
  @parser.attr(self, name, value)
end

- (Meteor::Element) attr(attr) - (Meteor::Element) attr(attr_name, attr_value) - (String) attr(attr_name)

Overloads:

  • - (Meteor::Element) attr(attr)

    set attribute of element (要素の属性をセットする)

    Parameters:

    • attr (Hash)

      attribute map (属性)

    Returns:

  • - (Meteor::Element) attr(attr_name, attr_value)

    set attribute of element (要素の属性をセットする)

    Parameters:

    • attr_name (String)

      attribute name (属性名)

    • attr_value (String, true, false)

      attribute value (属性値)

    Returns:

  • - (String) attr(attr_name)

    get attribute value of element (要素の属性値を取得する)

    Parameters:

    • attr_name (String)

      attribute name (属性名)

    Returns:

    • (String)

      attribute value (属性値)



339
340
341
# File 'lib/meteor.rb', line 339

def attr(attrs,*args)
  @parser.attr(self, attrs,*args)
end

- (Meteor::Element) attr_map(attr_map) - (Meteor::AttributeMap) attr_map

Overloads:



352
353
354
# File 'lib/meteor.rb', line 352

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

- (Meteor::Element) clone

clone (複製する)

Returns:



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/meteor.rb', line 160

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.usable = true
    obj
  else
    obj = self.new(self)
    self.parser.element_cache[self.object_id] = obj
    obj
  end
end

- (Meteor::Element) content(content, entity_ref = true) - (Meteor::Element) content(content) - (String) content

Overloads:

  • - (Meteor::Element) content(content, entity_ref = true)

    set content of element (要素の内容をセットする)

    Parameters:

    • content (String)

      content of element (要素の内容)

    • entity_ref (true, false)

      entity reference flag (エンティティ参照フラグ)

    Returns:

  • - (Meteor::Element) content(content)

    set content of element (要素の内容をセットする)

    Parameters:

    • content (String)

      content of element (要素の内容)

    Returns:

  • - (String) content

    get content of element (要素の内容を取得する)

    Returns:

    • (String)

      content (内容)



370
371
372
# File 'lib/meteor.rb', line 370

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

- (Meteor::Element) content=(value)

set content of element (内容をセットする)

Parameters:

  • value (String)

    content (内容)

Returns:



379
380
381
# File 'lib/meteor.rb', line 379

def content=(value)
  @parser.content(self, value)
end

- (Meteor::Element) cxtag(elm_name, id) - (Meteor::Element) cxtag(id)

get cx(comment extension) tag (CX(コメント拡張)タグを取得する)

Overloads:

  • - (Meteor::Element) cxtag(elm_name, id)

    要素名とID属性(id=“ID属性値”)でCX(コメント拡張)タグを取得する

    Parameters:

    • elm_name (String)

      要素名

    • id (String)

      ID属性値

    Returns:

  • - (Meteor::Element) cxtag(id)

    ID属性(id=“ID属性値”)でCX(コメント拡張)タグを取得する

    Parameters:

    • id (String)

      ID属性値

    Returns:



320
321
322
# File 'lib/meteor.rb', line 320

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

- (String) document

get document (ドキュメントを取得する)

Returns:

  • (String)

    document (ドキュメント)



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
# File 'lib/meteor.rb', line 204

def document
  if @document_sync then
    @document_sync = false
    case @parser.doc_type
      when Parser::HTML, Parser::HTML5 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::XHTML5, 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

- (Object) document=(doc)

set document (ドキュメントをセットする)

Parameters:

  • doc (String)

    document (ドキュメント)



195
196
197
198
# File 'lib/meteor.rb', line 195

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

- (Meteor::Element) element - (Meteor::Element) element(elm_name) - (Meteor::Element) element(elm_name, attrs) - (Meteor::Element) element(attrs) - (Meteor::Element) element(elm_name, attr_name, attr_value) - (Meteor::Element) element(attr_name, attr_value) - (Meteor::Element) element(elm_name, attr_name1, attr_value1, attr_name2, attr_value2) - (Meteor::Element) element(attr_name1, attr_value1, attr_name2, attr_value2) - (Meteor::Element) element(elm) Also known as: child

get element (要素を取得する)

Overloads:

  • - (Meteor::Element) element

    get element (要素を取得する)

    Returns:

  • - (Meteor::Element) element(elm_name)

    get element using element name (要素名で要素を取得する)

    Parameters:

    • elm_name (String)

      element name (要素名)

    Returns:

  • - (Meteor::Element) element(elm_name, attrs)

    get element using element name and attribute map (要素名と属性(属性名=“属性値”)あるいは属性1・属性2(属性名=“属性値”)で要素を取得する)

    Parameters:

    • elm_name (String)

      element name (要素名)

    • attrs (Hash)

      attribute map (属性マップ)

    Returns:

  • - (Meteor::Element) element(attrs)

    get element using attribute map (属性(属性名=“属性値”)あるいは属性1・属性2(属性名=“属性値”)で要素を取得する)

    Parameters:

    • attrs (Hash)

      attribute map (属性マップ)

    Returns:

  • - (Meteor::Element) element(elm_name, attr_name, attr_value)

    get element using element name and attribute(name=“value”) (要素名と属性(属性名=“属性値”)で要素を取得する)

    Parameters:

    • elm_name (String)

      element name (要素名)

    • attr_name (String)

      attribute name (属性名)

    • attr_value (String)

      attribute value (属性値)

    Returns:

  • - (Meteor::Element) element(attr_name, attr_value)

    get element using attribute(name=“value”) (属性(属性名=“属性値”)で要素を取得する)

    Parameters:

    • attr_name (String)

      属性名

    • attr_value (String)

      属性値

    Returns:

  • - (Meteor::Element) element(elm_name, attr_name1, attr_value1, attr_name2, attr_value2)

    get element using element name and attribute1,2(name=“value”) (要素名と属性1・属性2(属性名=“属性値”)で要素を取得する)

    Parameters:

    • elm_name (String)

      element name (要素名)

    • attr_name1 (String)

      attribute name1 (属性名1)

    • attr_value1 (String)

      attribute value1 (属性値1)

    • attr_name2 (String)

      attribute name2 (属性名2)

    • attr_value2 (String)

      attribute value2 (属性値2)

    Returns:

  • - (Meteor::Element) element(attr_name1, attr_value1, attr_name2, attr_value2)

    get element using attribute1,2(name=“value”) (属性1・属性2(属性名=“属性値”)で要素を取得する)

    Parameters:

    • attr_name1 (String)

      属性名1

    • attr_value1 (String)

      属性値1

    • attr_name2 (String)

      属性名2

    • attr_value2 (String)

      属性値2

    Returns:

  • - (Meteor::Element) element(elm)

    mirror element (要素を射影する)

    Parameters:

    Returns:



287
288
289
290
291
292
293
294
295
# File 'lib/meteor.rb', line 287

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

- (Object) execute(hook) - (Object) execute(loop, list)

Overloads:

  • - (Object) execute(hook)

    run action of Hooker (Hookerクラスの処理を実行する)

    Parameters:

  • - (Object) execute(loop, list)

    run action of Looper (Looperクラスの処理を実行する)

    Parameters:



434
435
436
# File 'lib/meteor.rb', line 434

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

- (Meteor::Element) find(selector)

get child element using selector (子要素を取得する)

Parameters:

  • selector (String)

    selector (セレクタ)

Returns:



304
305
306
# File 'lib/meteor.rb', line 304

def find(selector)
  @parser.find(selector)
end

- (Object) flush

reflect (反映する)



421
422
423
# File 'lib/meteor.rb', line 421

def flush
  @parser.flush
end

- (Object) remove

remove element (要素を削除する)



414
415
416
# File 'lib/meteor.rb', line 414

def remove
  @parser.remove_element(self)
end

- (Meteor::Element) remove_attr(attr_name)

remove attribute of element (要素の属性を消す)

Parameters:

  • attr_name (String)

    attribute name (属性名)

Returns:



407
408
409
# File 'lib/meteor.rb', line 407

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