Class: VCardio::Parameter

Inherits:
Object
  • Object
show all
Defined in:
lib/vcardio/parameter.rb

Overview

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’]‘.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, value) ⇒ Parameter

Returns a new instance of Parameter.



14
15
16
17
# File 'lib/vcardio/parameter.rb', line 14

def initialize(name, value)
  @name = name.to_s.upcase
  @value = value
end

Instance Attribute Details

#nameString (readonly)

Returns the current value of name.

Returns:

  • (String)

    the current value of name



13
14
15
# File 'lib/vcardio/parameter.rb', line 13

def name
  @name
end

#valueString, Array (readonly)

Returns the current value of value.

Returns:

  • (String, Array)

    the current value of value



13
14
15
# File 'lib/vcardio/parameter.rb', line 13

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object



28
29
30
31
32
# File 'lib/vcardio/parameter.rb', line 28

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

#to_abnf(_spec) ⇒ Object



21
22
23
24
25
26
# File 'lib/vcardio/parameter.rb', line 21

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