Class: Converter
- Inherits:
-
Object
- Object
- Converter
- Defined in:
- lib/vimamsa/text_transforms.rb
Instance Method Summary collapse
- #apply(txt) ⇒ Object
-
#initialize(obj, type, id = nil) ⇒ Converter
constructor
A new instance of Converter.
Constructor Details
#initialize(obj, type, id = nil) ⇒ Converter
Returns a new instance of Converter.
2 3 4 5 6 7 8 |
# File 'lib/vimamsa/text_transforms.rb', line 2 def initialize(obj, type, id = nil) @obj = obj @type = type if id != nil $vma.reg_conv(self, id) end end |
Instance Method Details
#apply(txt) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/vimamsa/text_transforms.rb', line 10 def apply(txt) if @type == :gsub return txt.gsub(@obj[0], @obj[1]) elsif @type == :lambda return @obj.call(txt) end end |