Class: Virginity::Vcard::Patching::Remove

Inherits:
Patch
  • Object
show all
Defined in:
lib/virginity/vcard/patching.rb

Overview

to remove fields matching a query

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Patch

#field_from_query, normalize_vcard!, query_for_line, query_from_string

Constructor Details

#initialize(query) ⇒ Remove

Returns a new instance of Remove.



163
164
165
# File 'lib/virginity/vcard/patching.rb', line 163

def initialize(query)
  @query = query
end

Instance Attribute Details

#queryObject

Returns the value of attribute query.



162
163
164
# File 'lib/virginity/vcard/patching.rb', line 162

def query
  @query
end

Instance Method Details

#apply(vcard) ⇒ Object



167
168
169
# File 'lib/virginity/vcard/patching.rb', line 167

def apply(vcard)
  vcard.delete(*vcard.where(@query))
end

#pretty_print(q) ⇒ Object



175
176
177
# File 'lib/virginity/vcard/patching.rb', line 175

def pretty_print(q)
  q.text "Remove #{@query}"
end

#to_sObject



171
172
173
# File 'lib/virginity/vcard/patching.rb', line 171

def to_s
  "Remove(#{@query.inspect})"
end