Class: Sablon::Parser::MailMerge::SimpleField

Inherits:
MergeField
  • Object
show all
Defined in:
lib/sablon/parser/mail_merge.rb

Constant Summary

Constants inherited from MergeField

MergeField::KEY_PATTERN

Instance Attribute Summary

Attributes inherited from MergeField

#block_reference_count

Instance Method Summary collapse

Methods inherited from MergeField

#expression, #valid?

Constructor Details

#initialize(node) ⇒ SimpleField

Returns a new instance of SimpleField.



94
95
96
97
98
# File 'lib/sablon/parser/mail_merge.rb', line 94

def initialize(node)
  super()
  @node = node
  @raw_expression = @node["w:instr"]
end

Instance Method Details

#ancestors(*args) ⇒ Object



116
117
118
# File 'lib/sablon/parser/mail_merge.rb', line 116

def ancestors(*args)
  @node.ancestors(*args)
end

#removeObject

removes only the merge field in question



107
108
109
# File 'lib/sablon/parser/mail_merge.rb', line 107

def remove
  remove_or_decrement_ref(@node)
end

#remove_parent(selector) ⇒ Object

removes the parent node containing the merge field



112
113
114
# File 'lib/sablon/parser/mail_merge.rb', line 112

def remove_parent(selector)
  remove_or_decrement_ref(@node.ancestors(selector).first)
end

#replace(content, env) ⇒ Object



100
101
102
103
104
# File 'lib/sablon/parser/mail_merge.rb', line 100

def replace(content, env)
  remove_extra_runs!
  replace_field_display(@node, content, env)
  @node.replace(@node.children)
end

#start_nodeObject Also known as: end_node



120
121
122
# File 'lib/sablon/parser/mail_merge.rb', line 120

def start_node
  @node
end