Class: Virginity::Params::Type::TypeArray
- Inherits:
-
SerializingArray
- Object
- SerializingArray
- Virginity::Params::Type::TypeArray
- Defined in:
- lib/virginity/vcard/field/params.rb
Constant Summary collapse
- LOCATIONS =
Locations are a subset of all the TYPE-params
{ "CELL" => "Mobile", "HOME" => "Home", "OTHER" => "Other", "WORK" => "Work" }
Instance Method Summary collapse
-
#initialize(field) ⇒ TypeArray
constructor
A new instance of TypeArray.
- #locations ⇒ Object
- #locations=(locs) ⇒ Object
-
#rewrite! ⇒ Object
def reload! @array = Array.new(@field.params(“TYPE”).map { |p| p.value }.uniq) self end.
Constructor Details
#initialize(field) ⇒ TypeArray
Returns a new instance of TypeArray.
8 9 10 11 |
# File 'lib/virginity/vcard/field/params.rb', line 8 def initialize(field) @field = field super(@field.params("TYPE").map { |p| p.value }.uniq) end |
Instance Method Details
#locations ⇒ Object
27 28 29 |
# File 'lib/virginity/vcard/field/params.rb', line 27 def locations @array.select { |t| LOCATIONS.keys.include?(t)} end |
#locations=(locs) ⇒ Object
31 32 33 34 |
# File 'lib/virginity/vcard/field/params.rb', line 31 def locations=(locs) locations.each {|l| delete(l) } locs.each { |l| self << l } end |
#rewrite! ⇒ Object
def reload!
@array = Array.new(@field.params("TYPE").map { |p| p.value }.uniq)
self
end
18 19 20 21 22 23 |
# File 'lib/virginity/vcard/field/params.rb', line 18 def rewrite! @field.params("TYPE").each {|t| @field.params.delete t } @array.each do |type| @field.params << Param.new('TYPE', type) end end |