Class: NoraMark::TransformerFactory
- Inherits:
-
Object
- Object
- NoraMark::TransformerFactory
- Defined in:
- lib/nora_mark/transformer.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#rules ⇒ Object
Returns the value of attribute rules.
Class Method Summary collapse
Instance Method Summary collapse
- #modify(selector, &block) ⇒ Object
- #rename(selector, name) ⇒ Object
- #replace(selector, &block) ⇒ Object
- #transform_options(options) ⇒ Object
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
34 35 36 |
# File 'lib/nora_mark/transformer.rb', line 34 def @options end |
#rules ⇒ Object
Returns the value of attribute rules.
34 35 36 |
# File 'lib/nora_mark/transformer.rb', line 34 def rules @rules end |
Class Method Details
.create(text: nil, &block) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/nora_mark/transformer.rb', line 36 def self.create(text: nil, &block) instance = new instance.instance_eval do @rules = [] @options = {} if text instance_eval text else instance_eval(&block) end Transformer.new(@rules, @options) end end |
Instance Method Details
#modify(selector, &block) ⇒ Object
54 55 56 |
# File 'lib/nora_mark/transformer.rb', line 54 def modify(selector, &block) @rules << [selector, :modify, block] end |
#rename(selector, name) ⇒ Object
62 63 64 |
# File 'lib/nora_mark/transformer.rb', line 62 def rename(selector, name) @rules << [selector, :modify, proc { @node.name = name }] end |
#replace(selector, &block) ⇒ Object
58 59 60 |
# File 'lib/nora_mark/transformer.rb', line 58 def replace(selector, &block) @rules << [selector, :replace, block] end |
#transform_options(options) ⇒ Object
50 51 52 |
# File 'lib/nora_mark/transformer.rb', line 50 def (@options ||= {}).merge end |