Class: Factbase::ToYAML
- Inherits:
-
Object
- Object
- Factbase::ToYAML
- Defined in:
- lib/factbase/to_yaml.rb
Overview
Instance Method Summary collapse
-
#initialize(fb, sorter = '_id') ⇒ ToYAML
constructor
Constructor.
-
#yaml ⇒ String
Convert the entire factbase into YAML.
Constructor Details
#initialize(fb, sorter = '_id') ⇒ ToYAML
Constructor.
39 40 41 42 |
# File 'lib/factbase/to_yaml.rb', line 39 def initialize(fb, sorter = '_id') @fb = fb @sorter = sorter end |
Instance Method Details
#yaml ⇒ String
Convert the entire factbase into YAML.
46 47 48 49 |
# File 'lib/factbase/to_yaml.rb', line 46 def yaml maps = Marshal.load(@fb.export) YAML.dump({ 'facts' => maps.sort_by { |m| m[@sorter] }.map { |m| m.sort.to_h } }) end |