Class: Typst::Query
Instance Attribute Summary collapse
-
#format ⇒ Object
Returns the value of attribute format.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(selector, input, field: nil, one: false, format: "json", root: ".", font_paths: [], sys_inputs: {}) ⇒ Query
constructor
A new instance of Query.
- #result(raw: false) ⇒ Object
Methods inherited from Base
#bytes, #compile, #document, from_s, from_zip, #pages, #typst_args, #with_dependencies, #with_font_paths, #with_fonts, #with_inputs, #with_root, #write
Constructor Details
#initialize(selector, input, field: nil, one: false, format: "json", root: ".", font_paths: [], sys_inputs: {}) ⇒ Query
Returns a new instance of Query.
5 6 7 8 9 |
# File 'lib/query.rb', line 5 def initialize(selector, input, field: nil, one: false, format: "json", root: ".", font_paths: [], sys_inputs: {}) super(input, root: root, font_paths: font_paths, sys_inputs: sys_inputs) self.format = format @result = Typst::_query(selector, field, one, format, input, root, font_paths, File.dirname(__FILE__), false, sys_inputs) end |
Instance Attribute Details
#format ⇒ Object
Returns the value of attribute format.
3 4 5 |
# File 'lib/query.rb', line 3 def format @format end |
Instance Method Details
#result(raw: false) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/query.rb', line 11 def result(raw: false) case raw || format when "json" then JSON(@result) when "yaml" then YAML::safe_load(@result) else @result end end |