Class: Plesk::ParamBuilder::Block
- Inherits:
-
Object
- Object
- Plesk::ParamBuilder::Block
- Defined in:
- lib/plesk/param_builder.rb
Instance Attribute Summary collapse
-
#result ⇒ Object
Returns the value of attribute result.
Instance Method Summary collapse
-
#initialize ⇒ Block
constructor
A new instance of Block.
- #method_missing(key, value = nil, &block) ⇒ Object
Constructor Details
#initialize ⇒ Block
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
#result ⇒ Object
Returns the value of attribute result.
5 6 7 |
# File 'lib/plesk/param_builder.rb', line 5 def result @result end |