Class: Taro::Export::Base
- Inherits:
-
Object
- Object
- Taro::Export::Base
- Defined in:
- lib/taro/export/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Class Method Summary collapse
Instance Method Summary collapse
- #to_json ⇒ Object
- #to_yaml ⇒ Object
- #write_to_file(path: Taro.config.export_path, format: Taro.config.export_format) ⇒ Object
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
2 3 4 |
# File 'lib/taro/export/base.rb', line 2 def result @result end |
Class Method Details
.call(declarations: Taro.declarations.eager_load, title: Taro.config.api_name, version: Taro.config.api_version) ⇒ Object
4 5 6 |
# File 'lib/taro/export/base.rb', line 4 def self.call(declarations: Taro.declarations.eager_load, title: Taro.config.api_name, version: Taro.config.api_version, **) new.call(declarations:, title:, version:, **) end |
Instance Method Details
#to_json ⇒ Object
14 15 16 17 |
# File 'lib/taro/export/base.rb', line 14 def to_json(*) require 'json' JSON.pretty_generate(result) end |
#to_yaml ⇒ Object
19 20 21 22 |
# File 'lib/taro/export/base.rb', line 19 def to_yaml require 'yaml' desymbolize(result).to_yaml end |
#write_to_file(path: Taro.config.export_path, format: Taro.config.export_format) ⇒ Object
8 9 10 11 12 |
# File 'lib/taro/export/base.rb', line 8 def write_to_file(path: Taro.config.export_path, format: Taro.config.export_format) data = __send__("to_#{format}") # e.g. to_json, to_yaml FileUtils.mkdir_p(File.dirname(path)) File.write(path, data) end |