Sha256: 1c52975f69bb21dab3691b86c298b8e54076d05f7dcf4ad828fa3dff20ffe6ad

Contents?: true

Size: 719 Bytes

Versions: 3

Compression:

Stored size: 719 Bytes

Contents

require 'digest/md5'
require 'uri/common'

# A chunk is a pattern of text that can be protected
# and interrogated by a renderer. Each Chunk class has a 
# +pattern+ that states what sort of text it matches.
# Chunks are initalized by passing in the result of a
# match by its pattern. 
module Chunk
  class Abstract
	attr_reader :text, :revision

	def initialize(match_data, revision) @text = match_data[0]; @revision = revision end
	def pre_mask() "chunk#{self.id}start " end
	def post_mask() " chunk#{self.id}end" end
	def mask(content) "chunk#{self.id}chunk" end
	def revert(content) content.sub!( Regexp.new(mask(content)), text ) end
	def unmask(content) self if revert(content) end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
Pimki-1.1.092 app/models/chunks/chunk.rb
Pimki-1.2.092 app/models/chunks/chunk.rb
Pimki-1.3.092 app/models/chunks/chunk.rb