Class: Nitro::Morphing
- Inherits:
-
Object
- Object
- Nitro::Morphing
- Defined in:
- lib/nitro/compiler/morphing.rb
Overview
A compiler module that translates xml stream. Multiple ‘key’ attributes are supported per element.
Defined Under Namespace
Classes: Listener
Class Method Summary collapse
- .add_morpher(key, klass) ⇒ Object (also: add)
- .delete_morpher(key) ⇒ Object (also: delete)
- .emit_end(name) ⇒ Object
- .emit_start(name, attributes) ⇒ Object
- .morphers ⇒ Object
- .morphers=(hash) ⇒ Object
- .transform(source, compiler = nil) ⇒ Object
Class Method Details
.add_morpher(key, klass) ⇒ Object Also known as: add
251 252 253 |
# File 'lib/nitro/compiler/morphing.rb', line 251 def add_morpher(key, klass) @morphers[key.to_s] = klass end |
.delete_morpher(key) ⇒ Object Also known as: delete
256 257 258 |
# File 'lib/nitro/compiler/morphing.rb', line 256 def delete_morpher(key) @morphers.delete(key) end |
.emit_end(name) ⇒ Object
226 227 228 |
# File 'lib/nitro/compiler/morphing.rb', line 226 def self.emit_end(name) "</#{name}>" end |
.emit_start(name, attributes) ⇒ Object
221 222 223 224 |
# File 'lib/nitro/compiler/morphing.rb', line 221 def self.emit_start(name, attributes) attrs = attributes.map{ |k, v| %|#{k}="#{v}"| }.join(' ') attrs.blank? ? "<#{name}>" : "<#{name} #{attrs}>" end |
.morphers ⇒ Object
243 244 245 |
# File 'lib/nitro/compiler/morphing.rb', line 243 def morphers @morphers end |
.morphers=(hash) ⇒ Object
247 248 249 |
# File 'lib/nitro/compiler/morphing.rb', line 247 def morphers=(hash) @morphers = hash end |