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: [], resource_path: ".", ignore_system_fonts: false, sys_inputs: {}) ⇒ Query
constructor
A new instance of Query.
- #result(raw: false) ⇒ Object
- #to_s ⇒ Object
Methods inherited from Base
#compile, from_s, from_zip, #query, #typst_args, #typst_pdf_args, #typst_png_args, #with_dependencies, #with_font_paths, #with_fonts, #with_inputs, #with_root
Constructor Details
#initialize(selector, input, field: nil, one: false, format: "json", root: ".", font_paths: [], resource_path: ".", ignore_system_fonts: false, sys_inputs: {}) ⇒ Query
Returns a new instance of Query.
5 6 7 8 |
# File 'lib/query.rb', line 5 def initialize(selector, input, field: nil, one: false, format: "json", root: ".", font_paths: [], resource_path: ".", ignore_system_fonts: false, sys_inputs: {}) self.format = format @result = Typst::_query(selector, field, one, format, input, root, font_paths, resource_path, ignore_system_fonts, 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
10 11 12 13 14 15 16 |
# File 'lib/query.rb', line 10 def result(raw: false) case raw || format when "json" then JSON(@result) when "yaml" then YAML::safe_load(@result) else @result end end |
#to_s ⇒ Object
18 19 20 |
# File 'lib/query.rb', line 18 def to_s @result end |