Class: BuildMaster::TreeToObject
- Inherits:
-
Object
- Object
- BuildMaster::TreeToObject
- Defined in:
- lib/buildmaster/common/tree_to_object.rb
Class Method Summary collapse
Instance Method Summary collapse
- #convert ⇒ Object
-
#initialize(tree, object) ⇒ TreeToObject
constructor
A new instance of TreeToObject.
Constructor Details
#initialize(tree, object) ⇒ TreeToObject
Returns a new instance of TreeToObject.
17 18 19 20 |
# File 'lib/buildmaster/common/tree_to_object.rb', line 17 def initialize(tree, object) @tree = tree @object = object end |
Class Method Details
.from_yaml(content, object) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/buildmaster/common/tree_to_object.rb', line 22 def TreeToObject.from_yaml(content, object) tree = {} if (content.chomp!) tree = YAML.load(content) if (not tree.kind_of?(Hash)) raise "Format error for content:\n#{content}" end end return TreeToObject.new(tree, object).convert end |
Instance Method Details
#convert ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/buildmaster/common/tree_to_object.rb', line 34 def convert @tree.each_pair do |key, value| if (value.kind_of?(Array)) convert_array(key, value) elsif (value.kind_of?(Hash)) convert_hash(key, value) else convert_property(key, value) end end return @object end |