Class: Vobject::Property

Inherits:
Object
  • Object
show all
Defined in:
lib/vobject/property.rb

Constant Summary collapse

MAX_LINE_WIDTH =
75

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, options) ⇒ Property

Returns a new instance of Property.



9
10
11
12
13
14
15
16
# File 'lib/vobject/property.rb', line 9

def initialize key, options
  self.group = options[:group]
  self.prop_name = key
  self.params = options[:params]
  self.value = parse_value(options[:value])

  raise_invalid_initialization if key != name
end

Instance Attribute Details

#groupObject

Returns the value of attribute group.



7
8
9
# File 'lib/vobject/property.rb', line 7

def group
  @group
end

#paramsObject

Returns the value of attribute params.



7
8
9
# File 'lib/vobject/property.rb', line 7

def params
  @params
end

#prop_nameObject

Returns the value of attribute prop_name.



7
8
9
# File 'lib/vobject/property.rb', line 7

def prop_name
  @prop_name
end

#valueObject

Returns the value of attribute value.



7
8
9
# File 'lib/vobject/property.rb', line 7

def value
  @value
end

Instance Method Details

#to_sObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vobject/property.rb', line 18

def to_s
  line = group ? "#{group}." : ""
  line << "#{name}"

  (params || {}).each do |pname, pvalue|
    pvalue.to_s.gsub!(/\n/, '\n')

    line << ";#{pname}=#{pvalue}"
  end

  line << ":#{value}"

  line = fold_line(line) << "\n"

  line
end