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