Class: LlmScraper::Schema::Field
- Inherits:
-
Object
- Object
- LlmScraper::Schema::Field
- Defined in:
- lib/llm_scraper/schema.rb
Constant Summary collapse
- VALID_TYPES =
%i[string number boolean array object].freeze
Instance Attribute Summary collapse
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#enum ⇒ Object
readonly
Returns the value of attribute enum.
-
#examples ⇒ Object
readonly
Returns the value of attribute examples.
-
#how ⇒ Object
readonly
Returns the value of attribute how.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#required ⇒ Object
readonly
Returns the value of attribute required.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#what ⇒ Object
readonly
Returns the value of attribute what.
Instance Method Summary collapse
-
#has_instructions? ⇒ Boolean
True when field has extraction instructions beyond just a label.
-
#initialize(name:, type:, description: nil, what: nil, how: nil, examples: nil, enum: nil, required: false, default: nil, items: nil, **_rest) ⇒ Field
constructor
A new instance of Field.
Constructor Details
#initialize(name:, type:, description: nil, what: nil, how: nil, examples: nil, enum: nil, required: false, default: nil, items: nil, **_rest) ⇒ Field
Returns a new instance of Field.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/llm_scraper/schema.rb', line 42 def initialize(name:, type:, description: nil, what: nil, how: nil, examples: nil, enum: nil, required: false, default: nil, items: nil, **_rest) @name = name @type = type.to_sym @what = what || description @how = how @examples = examples @enum = enum @required = required @default = default @items = items validate! end |
Instance Attribute Details
#default ⇒ Object (readonly)
Returns the value of attribute default.
39 40 41 |
# File 'lib/llm_scraper/schema.rb', line 39 def default @default end |
#enum ⇒ Object (readonly)
Returns the value of attribute enum.
39 40 41 |
# File 'lib/llm_scraper/schema.rb', line 39 def enum @enum end |
#examples ⇒ Object (readonly)
Returns the value of attribute examples.
39 40 41 |
# File 'lib/llm_scraper/schema.rb', line 39 def examples @examples end |
#how ⇒ Object (readonly)
Returns the value of attribute how.
39 40 41 |
# File 'lib/llm_scraper/schema.rb', line 39 def how @how end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
39 40 41 |
# File 'lib/llm_scraper/schema.rb', line 39 def items @items end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
39 40 41 |
# File 'lib/llm_scraper/schema.rb', line 39 def name @name end |
#required ⇒ Object (readonly)
Returns the value of attribute required.
39 40 41 |
# File 'lib/llm_scraper/schema.rb', line 39 def required @required end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
39 40 41 |
# File 'lib/llm_scraper/schema.rb', line 39 def type @type end |
#what ⇒ Object (readonly)
Returns the value of attribute what.
39 40 41 |
# File 'lib/llm_scraper/schema.rb', line 39 def what @what end |
Instance Method Details
#has_instructions? ⇒ Boolean
True when field has extraction instructions beyond just a label
59 60 61 |
# File 'lib/llm_scraper/schema.rb', line 59 def has_instructions? !@how.nil? || !@examples.nil? || !@enum.nil? end |