class Transform
Attributes
property[RW]
type[RW]
Public Class Methods
new(type, property)
click to toggle source
# File lib/pertinent_parser/transform.rb, line 4 def initialize type, property @type, @property = type, property end
Public Instance Methods
apply(s)
click to toggle source
# File lib/pertinent_parser/transform.rb, line 16 def apply(s) if @type == :identity return s elsif @type == :replacement return @property elsif @type == :wrap return @property[0] + s + @property[1] end end
split(n)
click to toggle source
# File lib/pertinent_parser/transform.rb, line 8 def split(n) if @type == :replacement return [Transform.new(:replacement, @property[0..n-1]), Transform.new(:replacement, @property[n..-1])] elsif @type == :wrap return [self, self.dup] end end