Class: Xmlss::Writer::Markup
- Inherits:
-
Object
- Object
- Xmlss::Writer::Markup
- Defined in:
- lib/xmlss/writer.rb
Instance Attribute Summary collapse
-
#pop_count ⇒ Object
readonly
Returns the value of attribute pop_count.
-
#push_count ⇒ Object
readonly
Returns the value of attribute push_count.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #element(name, data, attrs) ⇒ Object
- #empty? ⇒ Boolean
- #flush ⇒ Object
-
#initialize(opts = {}) ⇒ Markup
constructor
A new instance of Markup.
- #inline_element(name, attrs) ⇒ Object
- #pop ⇒ Object
- #push ⇒ Object
- #raw(markup) ⇒ Object
- #to_s ⇒ Object
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_count ⇒ Object (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_count ⇒ Object (readonly)
Returns the value of attribute push_count.
215 216 217 |
# File 'lib/xmlss/writer.rb', line 215 def push_count @push_count end |
#template ⇒ Object (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
256 |
# File 'lib/xmlss/writer.rb', line 256 def empty?; @markup.empty?; end |
#flush ⇒ Object
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 |
#pop ⇒ Object
243 244 245 246 |
# File 'lib/xmlss/writer.rb', line 243 def pop @pop_count += 1 @template.__pop end |
#push ⇒ Object
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_s ⇒ Object
258 259 260 |
# File 'lib/xmlss/writer.rb', line 258 def to_s @markup.to_s end |