Class: Converter

Inherits:
Object
  • Object
show all
Defined in:
lib/vimamsa/text_transforms.rb

Instance Method Summary collapse

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