Class: Plesk::ParamBuilder::Block

Inherits:
Object
  • Object
show all
Defined in:
lib/plesk/param_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBlock

Returns a new instance of Block.



6
7
8
# File 'lib/plesk/param_builder.rb', line 6

def initialize
  @result = ""
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(key, value = nil, &block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/plesk/param_builder.rb', line 10

def method_missing(key, value = nil, &block)
  if block_given?
    @result += "<#{key}>"
    i = Block.new
    result = i.instance_exec(&block)
    @result += i.result
    unless result.nil?
      @result += result.to_s
    end
    @result += "</#{key}>"
  elsif value
    @result += "<#{key}>#{value}</#{key}>"
  else
    @result += "<#{key} />"
  end

  nil
end

Instance Attribute Details

#resultObject

Returns the value of attribute result.



5
6
7
# File 'lib/plesk/param_builder.rb', line 5

def result
  @result
end