Class: VCardio::Parameter
- Inherits:
-
Object
- Object
- VCardio::Parameter
- 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
-
#name ⇒ String
readonly
The current value of name.
-
#value ⇒ String, Array
readonly
The current value of value.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(name, value) ⇒ Parameter
constructor
A new instance of Parameter.
- #to_abnf(_spec) ⇒ Object
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
#name ⇒ String (readonly)
Returns the current value of name.
13 14 15 |
# File 'lib/vcardio/parameter.rb', line 13 def name @name end |
#value ⇒ String, Array (readonly)
Returns 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 |