Class: Kwartz::ElementInfo

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stag_info, etag_info, cont_stmts, attr_info, append_exprs) ⇒ ElementInfo

Returns a new instance of ElementInfo.



162
163
164
165
166
167
168
169
# File 'lib/kwartz/converter.rb', line 162

def initialize(stag_info, etag_info, cont_stmts, attr_info, append_exprs)
  @stag_info    = stag_info      # TagInfo
  @etag_info    = etag_info      # TagInfo
  @cont_stmts   = cont_stmts     # list of Statement
  @attr_info    = attr_info      # AttrInfo
  @append_exprs = append_exprs   # list of NativeExpression
  @logic = [ ExpandStatement.new(:elem, @name) ]
end

Instance Attribute Details

#afterObject (readonly)

Returns the value of attribute after.



173
174
175
# File 'lib/kwartz/converter.rb', line 173

def after
  @after
end

#append_exprsObject

Returns the value of attribute append_exprs.



171
172
173
# File 'lib/kwartz/converter.rb', line 171

def append_exprs
  @append_exprs
end

#appliedObject

Returns the value of attribute applied.



175
176
177
# File 'lib/kwartz/converter.rb', line 175

def applied
  @applied
end

#attr_infoObject

Returns the value of attribute attr_info.



171
172
173
# File 'lib/kwartz/converter.rb', line 171

def attr_info
  @attr_info
end

#beforeObject (readonly)

Returns the value of attribute before.



173
174
175
# File 'lib/kwartz/converter.rb', line 173

def before
  @before
end

#cont_exprObject (readonly)

Returns the value of attribute cont_expr.



172
173
174
# File 'lib/kwartz/converter.rb', line 172

def cont_expr
  @cont_expr
end

#cont_stmtsObject

Returns the value of attribute cont_stmts.



171
172
173
# File 'lib/kwartz/converter.rb', line 171

def cont_stmts
  @cont_stmts
end

#elem_exprObject (readonly)

Returns the value of attribute elem_expr.



172
173
174
# File 'lib/kwartz/converter.rb', line 172

def elem_expr
  @elem_expr
end

#etag_exprObject (readonly)

Returns the value of attribute etag_expr.



172
173
174
# File 'lib/kwartz/converter.rb', line 172

def etag_expr
  @etag_expr
end

#etag_infoObject

Returns the value of attribute etag_info.



171
172
173
# File 'lib/kwartz/converter.rb', line 171

def etag_info
  @etag_info
end

#logicObject (readonly)

Returns the value of attribute logic.



173
174
175
# File 'lib/kwartz/converter.rb', line 173

def logic
  @logic
end

#nameObject

Returns the value of attribute name.



174
175
176
# File 'lib/kwartz/converter.rb', line 174

def name
  @name
end

#stag_exprObject (readonly)

Returns the value of attribute stag_expr.



172
173
174
# File 'lib/kwartz/converter.rb', line 172

def stag_expr
  @stag_expr
end

#stag_infoObject

Returns the value of attribute stag_info.



171
172
173
# File 'lib/kwartz/converter.rb', line 171

def stag_info
  @stag_info
end

Class Method Details

.create(values = {}) ⇒ Object



178
179
180
181
# File 'lib/kwartz/converter.rb', line 178

def self.create(values={})
  v = values
  return self.new(v[:name], v[:stag], v[:etag], v[:cont], v[:attr], v[:append])
end

Instance Method Details

#apply(ruleset) ⇒ Object



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
# File 'lib/kwartz/converter.rb', line 184

def apply(ruleset)
  r = ruleset
  @stag_expr = _to_native_expr(r.stag) if r.stag
  @cont_expr = _to_native_expr(r.cont) if r.cont
  @etag_expr = _to_native_expr(r.etag) if r.etag
  @elem_expr = _to_native_expr(r.elem) if r.elem
  if @cont_expr
    @cont_stmts = [ PrintStatement.new([@cont_expr]) ]
    @stag_info.tail_space = ''
    @etag_info.head_space = ''
    @etag_info.rebuild_tag_text()
  end
  r.remove.each do |aname|
    @attr_info.delete(aname)
  end if r.remove
  r.attrs.each do |aname, avalue|
    @attr_info[aname] = _to_native_expr(avalue)
  end if r.attrs
  r.append.each do |expr|
    (@append_exprs ||= []) << _to_native_expr(expr)
  end if r.append
  @tagname = r.tagname if r.tagname
  @logic  = r.logic  if r.logic
  (@before ||= []).concat(r.before) if r.before
  (@after  ||= []).concat(r.after)  if r.after
end

#dummy_span_tag?(tagname = 'span') ⇒ Boolean

Returns:

  • (Boolean)


212
213
214
# File 'lib/kwartz/converter.rb', line 212

def dummy_span_tag?(tagname='span')
  return @stag_info.tagname == tagname && @attr_info.empty?  && @append_exprs.nil?
end