Class: Masterplan::Document
- Inherits:
-
Hash
- Object
- Hash
- Masterplan::Document
- Defined in:
- lib/masterplan/document.rb
Instance Method Summary collapse
-
#initialize(hash = {}) ⇒ Document
constructor
A new instance of Document.
-
#to_hash ⇒ Object
Turns a Masterplan::Document into a plain Hash - this removes all special objects like Masterplan::Rule and replaces them with their example values, so the result can be used as documentation.
Constructor Details
#initialize(hash = {}) ⇒ Document
Returns a new instance of Document.
4 5 6 7 8 9 |
# File 'lib/masterplan/document.rb', line 4 def initialize(hash = {}) raise ArgumentError, "Can only work with a Hash, not a #{hash.class.name} !" unless hash.is_a?(Hash) hash.each do |k, v| self[k] = v end end |
Instance Method Details
#to_hash ⇒ Object
Turns a Masterplan::Document into a plain Hash - this removes all special objects like Masterplan::Rule and replaces them with their example values, so the result can be used as documentation.
14 15 16 17 18 19 20 |
# File 'lib/masterplan/document.rb', line 14 def to_hash result = {} each do |k, v| result[self.class.derulerize(k)] = self.class.derulerize(v) end result end |