Class: DeepAgentsRb::Todo
- Inherits:
-
Object
- Object
- DeepAgentsRb::Todo
- Defined in:
- lib/deepagents/deepagentsrb/state.rb
Overview
Todo class for managing todos
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#status ⇒ Object
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(content, status = "pending") ⇒ Todo
constructor
A new instance of Todo.
- #to_h ⇒ Object
Constructor Details
#initialize(content, status = "pending") ⇒ Todo
Returns a new instance of Todo.
8 9 10 11 12 |
# File 'lib/deepagents/deepagentsrb/state.rb', line 8 def initialize(content, status = "pending") raise ArgumentError, "Todo content cannot be nil or empty" if content.nil? || content.empty? @content = content @status = validate_status(status) end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
6 7 8 |
# File 'lib/deepagents/deepagentsrb/state.rb', line 6 def content @content end |
#status ⇒ Object
Returns the value of attribute status.
6 7 8 |
# File 'lib/deepagents/deepagentsrb/state.rb', line 6 def status @status end |
Class Method Details
.from_h(hash) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/deepagents/deepagentsrb/state.rb', line 21 def self.from_h(hash) content = hash[:content] || hash["content"] status = hash[:status] || hash["status"] || "pending" raise ArgumentError, "Todo hash must contain content" if content.nil? new(content, status) end |
Instance Method Details
#to_h ⇒ Object
14 15 16 17 18 19 |
# File 'lib/deepagents/deepagentsrb/state.rb', line 14 def to_h { content: @content, status: @status } end |