Class: RubyLLM::Contract::Prompt::AST
- Inherits:
-
Object
- Object
- RubyLLM::Contract::Prompt::AST
- Includes:
- Enumerable
- Defined in:
- lib/ruby_llm/contract/prompt/ast.rb
Instance Attribute Summary collapse
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #[](index) ⇒ Object
- #each ⇒ Object
-
#initialize(nodes) ⇒ AST
constructor
A new instance of AST.
- #size ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(nodes) ⇒ AST
Returns a new instance of AST.
11 12 13 14 |
# File 'lib/ruby_llm/contract/prompt/ast.rb', line 11 def initialize(nodes) @nodes = nodes.dup.freeze freeze end |
Instance Attribute Details
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
9 10 11 |
# File 'lib/ruby_llm/contract/prompt/ast.rb', line 9 def nodes @nodes end |
Instance Method Details
#==(other) ⇒ Object
28 29 30 |
# File 'lib/ruby_llm/contract/prompt/ast.rb', line 28 def ==(other) other.is_a?(self.class) && nodes == other.nodes end |
#[](index) ⇒ Object
24 25 26 |
# File 'lib/ruby_llm/contract/prompt/ast.rb', line 24 def [](index) @nodes[index] end |
#each ⇒ Object
16 17 18 |
# File 'lib/ruby_llm/contract/prompt/ast.rb', line 16 def each(&) @nodes.each(&) end |
#size ⇒ Object
20 21 22 |
# File 'lib/ruby_llm/contract/prompt/ast.rb', line 20 def size @nodes.size end |
#to_a ⇒ Object
32 33 34 |
# File 'lib/ruby_llm/contract/prompt/ast.rb', line 32 def to_a @nodes.map(&:to_h) end |