Class: AIHype::ApprovalPrompt

Inherits:
Object
  • Object
show all
Defined in:
lib/aihype/approval_prompt.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, raw_text:, detected_patterns: [], confidence: 0.0, is_menu: false) ⇒ ApprovalPrompt

Returns a new instance of ApprovalPrompt.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/aihype/approval_prompt.rb', line 7

def initialize(id:, raw_text:, detected_patterns: [], confidence: 0.0, is_menu: false)
  @id = id
  @timestamp = Time.now
  @raw_text = raw_text
  @detected_patterns = detected_patterns
  @confidence = confidence
  @matched_rule = nil
  @decision = :pending
  @response_sent = nil
  @is_menu = is_menu
end

Instance Attribute Details

#confidenceObject (readonly)

Returns the value of attribute confidence.



5
6
7
# File 'lib/aihype/approval_prompt.rb', line 5

def confidence
  @confidence
end

#decisionObject (readonly)

Returns the value of attribute decision.



5
6
7
# File 'lib/aihype/approval_prompt.rb', line 5

def decision
  @decision
end

#detected_patternsObject (readonly)

Returns the value of attribute detected_patterns.



5
6
7
# File 'lib/aihype/approval_prompt.rb', line 5

def detected_patterns
  @detected_patterns
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/aihype/approval_prompt.rb', line 5

def id
  @id
end

#is_menuObject (readonly)

Returns the value of attribute is_menu.



5
6
7
# File 'lib/aihype/approval_prompt.rb', line 5

def is_menu
  @is_menu
end

#matched_ruleObject (readonly)

Returns the value of attribute matched_rule.



5
6
7
# File 'lib/aihype/approval_prompt.rb', line 5

def matched_rule
  @matched_rule
end

#raw_textObject (readonly)

Returns the value of attribute raw_text.



5
6
7
# File 'lib/aihype/approval_prompt.rb', line 5

def raw_text
  @raw_text
end

#response_sentObject (readonly)

Returns the value of attribute response_sent.



5
6
7
# File 'lib/aihype/approval_prompt.rb', line 5

def response_sent
  @response_sent
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



5
6
7
# File 'lib/aihype/approval_prompt.rb', line 5

def timestamp
  @timestamp
end

Instance Method Details

#ai_unavailable_approve!(response = nil) ⇒ Object



30
31
32
33
# File 'lib/aihype/approval_prompt.rb', line 30

def ai_unavailable_approve!(response = nil)
  @decision = :ai_unavailable_approved
  @response_sent = response || default_approve_response
end

#approve!(response = nil) ⇒ Object



19
20
21
22
# File 'lib/aihype/approval_prompt.rb', line 19

def approve!(response = nil)
  @decision = :approved
  @response_sent = response || default_approve_response
end

#approved?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/aihype/approval_prompt.rb', line 35

def approved?
  @decision == :approved || @decision == :ai_unavailable_approved
end

#denied?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/aihype/approval_prompt.rb', line 39

def denied?
  @decision == :denied
end

#deny!(rule_id, response = nil) ⇒ Object



24
25
26
27
28
# File 'lib/aihype/approval_prompt.rb', line 24

def deny!(rule_id, response = nil)
  @decision = :denied
  @matched_rule = rule_id
  @response_sent = response || default_deny_response
end