Class: YAMLRewriter::Rewriter
- Inherits:
-
Object
- Object
- YAMLRewriter::Rewriter
- Defined in:
- lib/yaml_rewriter/rewriter.rb
Overview
Usage:
class MyRewriter < YAMLRewriter::Rewriter
define_rule ['foo' => 'bar']
define_rule ['one', 'two', 'threeee' => 'three']
end
MyRewriter.new('foo: baz').rewrite # => 'bar: baz'
rewriter = MyRewriter.new(<<-END)
one:
two:
threeee: 123
END
rewriter.rewrite # => one:
two:
three: 123
Direct Known Subclasses
Mry::Rewriters::Rewriter_0, Mry::Rewriters::Rewriter_0_41_0, Mry::Rewriters::Rewriter_0_42_0, Mry::Rewriters::Rewriter_0_43_0, Mry::Rewriters::Rewriter_0_44_0, Mry::Rewriters::Rewriter_0_45_0, Mry::Rewriters::Rewriter_0_46_0, Mry::Rewriters::Rewriter_0_47_0, Mry::Rewriters::Rewriter_0_48_0, Mry::Rewriters::Rewriter_0_49_0, Mry::Rewriters::Rewriter_0_50_0, Mry::Rewriters::Rewriter_0_51_0, Mry::Rewriters::Rewriter_0_52_0, Mry::Rewriters::Rewriter_0_53_0, Mry::Rewriters::Rewriter_0_54_0, Mry::Rewriters::Rewriter_0_55_0, Mry::Rewriters::Rewriter_0_56_0, Mry::Rewriters::Rewriter_0_57_0, Mry::Rewriters::Rewriter_0_58_0, Mry::Rewriters::Rewriter_0_59_0, Mry::Rewriters::Rewriter_0_60_0, Mry::Rewriters::Rewriter_0_61_0, Mry::Rewriters::Rewriter_0_62_0, Mry::Rewriters::Rewriter_0_63_0, Mry::Rewriters::Rewriter_0_64_0, Mry::Rewriters::Rewriter_0_65_0, Mry::Rewriters::Rewriter_0_66_0, Mry::Rewriters::Rewriter_0_67_0, Mry::Rewriters::Rewriter_0_68_0, Mry::Rewriters::Rewriter_0_69_0, Mry::Rewriters::Rewriter_0_70_0, Mry::Rewriters::Rewriter_0_71_0, Mry::Rewriters::Rewriter_0_72_0, Mry::Rewriters::Rewriter_0_73_0, Mry::Rewriters::Rewriter_0_74_0, Mry::Rewriters::Rewriter_0_75_0, Mry::Rewriters::Rewriter_0_76_0, Mry::Rewriters::Rewriter_0_77_0, Mry::Rewriters::Rewriter_0_78_0, Mry::Rewriters::Rewriter_Master
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(yaml, reverse: false) ⇒ Rewriter
constructor
A new instance of Rewriter.
- #rewrite ⇒ String
Constructor Details
#initialize(yaml, reverse: false) ⇒ Rewriter
Returns a new instance of Rewriter.
22 23 24 25 26 |
# File 'lib/yaml_rewriter/rewriter.rb', line 22 def initialize(yaml, reverse: false) @yaml = yaml.dup @reverse = reverse @offset = 0 end |