Sha256: d5e72f7fae5370e1cda33a87b82f105a5eb4c8cbaa1e3135599adfb78a54ad6a

Contents?: true

Size: 742 Bytes

Versions: 2

Compression:

Stored size: 742 Bytes

Contents

module VCardio
  #
  # Name/value parameter pair of a content line definition.
  #
  # Given the content line:
  #   `item1.TEL;type=WORK,HOME:+1 617 555 1212`
  #
  # The parameter name will be `type` and value will be `['WORK', 'HOME']`.
  #
  # @attr_reader [String] name
  # @attr_reader [String,Array] value
  #
  class Parameter
    def initialize(name, value)
      @name = name.to_s.upcase
      @value = value
    end

    attr_reader :name, :value

    def to_abnf(_spec)
      abnf = @name
      abnf += '='
      abnf += @value.is_a?(Array) ? @value.join(',') : @value.to_s
      abnf
    end

    def ==(other)
      other.is_a?(VCardio::Parameter) &&
        name == other.name &&
        value == other.value
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vcardio-0.1.1 lib/vcardio/parameter.rb
vcardio-0.1.0 lib/vcardio/parameter.rb