Class: LlmScraper::Schema
- Inherits:
-
Object
- Object
- LlmScraper::Schema
- Defined in:
- lib/llm_scraper/schema.rb
Defined Under Namespace
Classes: Field
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
Class Method Summary collapse
Instance Method Summary collapse
- #field(name, type:, **options) ⇒ Object
-
#initialize ⇒ Schema
constructor
A new instance of Schema.
Constructor Details
#initialize ⇒ Schema
Returns a new instance of Schema.
25 26 27 |
# File 'lib/llm_scraper/schema.rb', line 25 def initialize @fields = {} end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
5 6 7 |
# File 'lib/llm_scraper/schema.rb', line 5 def fields @fields end |
Class Method Details
.define(&block) ⇒ Schema
9 10 11 12 13 |
# File 'lib/llm_scraper/schema.rb', line 9 def self.define(&block) schema = new schema.instance_eval(&block) schema end |
.from_hash(hash) ⇒ Schema
17 18 19 20 21 22 23 |
# File 'lib/llm_scraper/schema.rb', line 17 def self.from_hash(hash) schema = new hash.each do |name, opts| schema.field(name.to_sym, **opts.transform_keys(&:to_sym)) end schema end |