Class: Factbase::ToYAML
- Inherits:
-
Object
- Object
- Factbase::ToYAML
- Defined in:
- lib/factbase/to_yaml.rb
Overview
Factbase to YAML converter.
This class helps converting an entire Factbase to YAML format, for example:
require 'factbase/to_yaml'
fb = Factbase.new
puts Factbase::ToYAML.new(fb).yaml
- Author
-
Yegor Bugayenko ([email protected])
- Copyright
-
Copyright © 2024-2025 Yegor Bugayenko
- License
-
MIT
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.
23 24 25 26 |
# File 'lib/factbase/to_yaml.rb', line 23 def initialize(fb, sorter = '_id') @fb = fb @sorter = sorter end |
Instance Method Details
#yaml ⇒ String
Convert the entire factbase into YAML.
30 31 32 |
# File 'lib/factbase/to_yaml.rb', line 30 def yaml YAML.dump(Factbase::Flatten.new(Marshal.load(@fb.export), @sorter).it) end |