Class: VCardio::Builder::PropertyBuilder

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

Instance Method Summary collapse

Constructor Details

#initialize(name, args) ⇒ PropertyBuilder

Returns a new instance of PropertyBuilder.



31
32
33
34
35
# File 'lib/vcardio/builder.rb', line 31

def initialize(name, args)
  @args  = args
  @group = nil
  @name  = name
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object



56
57
58
59
60
61
# File 'lib/vcardio/builder.rb', line 56

def method_missing(method_name, *args)
  @group = @name
  @name  = method_name
  @args  = args
  self
end

Instance Method Details

#build_parameters(hash) ⇒ Object



37
38
39
40
41
42
43
44
45
46
# File 'lib/vcardio/builder.rb', line 37

def build_parameters(hash)
  hash ||= {}
  parameters = []

  hash.each do |k, v|
    parameters << VCardio::Parameter.new(k, v)
  end

  parameters
end

#to_propertyObject



48
49
50
51
52
53
54
# File 'lib/vcardio/builder.rb', line 48

def to_property
  args       = @args.clone
  value      = args.shift
  parameters = build_parameters(args[0])

  VCardio::Property.new(@group, @name, parameters, value)
end