Class: Xmlss::Writer::Markup

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Markup

Returns a new instance of Markup.



217
218
219
220
221
222
# File 'lib/xmlss/writer.rb', line 217

def initialize(opts={})
  @markup = ""
  @template = Undies::Template.new(Undies::IO.new(@markup, opts))
  @push_count = 0
  @pop_count  = 0
end

Instance Attribute Details

#pop_countObject (readonly)

Returns the value of attribute pop_count.



215
216
217
# File 'lib/xmlss/writer.rb', line 215

def pop_count
  @pop_count
end

#push_countObject (readonly)

Returns the value of attribute push_count.



215
216
217
# File 'lib/xmlss/writer.rb', line 215

def push_count
  @push_count
end

#templateObject (readonly)

Returns the value of attribute template.



215
216
217
# File 'lib/xmlss/writer.rb', line 215

def template
  @template
end

Instance Method Details

#element(name, data, attrs) ⇒ Object



230
231
232
# File 'lib/xmlss/writer.rb', line 230

def element(name, data, attrs)
  @template.__open_element(name, data, attrs)
end

#empty?Boolean

Returns:

  • (Boolean)


256
# File 'lib/xmlss/writer.rb', line 256

def empty?; @markup.empty?; end

#flushObject



248
249
250
251
252
253
254
# File 'lib/xmlss/writer.rb', line 248

def flush
  while @push_count > @pop_count
    pop
  end
  @template.__flush
  self
end

#inline_element(name, attrs) ⇒ Object



234
235
236
# File 'lib/xmlss/writer.rb', line 234

def inline_element(name, attrs)
  @template.__closed_element(name, attrs)
end

#popObject



243
244
245
246
# File 'lib/xmlss/writer.rb', line 243

def pop
  @pop_count += 1
  @template.__pop
end

#pushObject



238
239
240
241
# File 'lib/xmlss/writer.rb', line 238

def push
  @push_count += 1
  @template.__push
end

#raw(markup) ⇒ Object



224
225
226
227
228
# File 'lib/xmlss/writer.rb', line 224

def raw(markup)
  @template.raw(
    Undies::Template.escape_html(markup).gsub(/(\r|\n)+/, Xmlss::Writer::LB)
  )
end

#to_sObject



258
259
260
# File 'lib/xmlss/writer.rb', line 258

def to_s
  @markup.to_s
end