Class: Chunk::Abstract

Inherits:
Object
  • Object
show all
Defined in:
app/models/chunks/chunk.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(match_data, revision) ⇒ Abstract

Returns a new instance of Abstract.



13
# File 'app/models/chunks/chunk.rb', line 13

def initialize(match_data, revision) @text = match_data[0]; @revision = revision end

Instance Attribute Details

#revisionObject (readonly)

Returns the value of attribute revision.



11
12
13
# File 'app/models/chunks/chunk.rb', line 11

def revision
  @revision
end

#textObject (readonly)

Returns the value of attribute text.



11
12
13
# File 'app/models/chunks/chunk.rb', line 11

def text
  @text
end

Instance Method Details

#mask(content) ⇒ Object



16
# File 'app/models/chunks/chunk.rb', line 16

def mask(content) "chunk#{self.object_id}chunk" end

#post_maskObject



15
# File 'app/models/chunks/chunk.rb', line 15

def post_mask() " chunk#{self.object_id}end" end

#pre_maskObject



14
# File 'app/models/chunks/chunk.rb', line 14

def pre_mask() "chunk#{self.object_id}start " end

#revert(content) ⇒ Object



17
# File 'app/models/chunks/chunk.rb', line 17

def revert(content) content.sub!( Regexp.new(mask(content)), text ) end

#unmask(content) ⇒ Object



18
# File 'app/models/chunks/chunk.rb', line 18

def unmask(content) self if revert(content) end