Class: Virginity::Vcard::Patching::Add

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

Overview

to add a field

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(line) ⇒ Add

Returns a new instance of Add.



142
143
144
# File 'lib/virginity/vcard/patching.rb', line 142

def initialize(line)
  @field = Field.parse(line)
end

Instance Attribute Details

#fieldObject

Returns the value of attribute field.



141
142
143
# File 'lib/virginity/vcard/patching.rb', line 141

def field
  @field
end

Instance Method Details

#apply(vcard) ⇒ Object



146
147
148
# File 'lib/virginity/vcard/patching.rb', line 146

def apply(vcard)
  vcard.add_field(@field)
end

#pretty_print(q) ⇒ Object



154
155
156
# File 'lib/virginity/vcard/patching.rb', line 154

def pretty_print(q)
  q.text "Add #{@field}"
end

#to_sObject



150
151
152
# File 'lib/virginity/vcard/patching.rb', line 150

def to_s
  "Add(#{@field.inspect})"
end