Class: Mailscope::Query
- Inherits:
-
Object
- Object
- Mailscope::Query
- Defined in:
- lib/mailscope/query.rb
Overview
Filters the in-memory message list. Small enough to stay honest about what it does: no index, just a scan over metadata that is already loaded.
Instance Attribute Summary collapse
-
#mailbox ⇒ Object
readonly
Returns the value of attribute mailbox.
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
-
#only ⇒ Object
readonly
Returns the value of attribute only.
-
#term ⇒ Object
readonly
Returns the value of attribute term.
Instance Method Summary collapse
- #filtered? ⇒ Boolean
-
#initialize(messages, mailbox: nil, term: nil, only: nil) ⇒ Query
constructor
A new instance of Query.
- #results ⇒ Object
Constructor Details
#initialize(messages, mailbox: nil, term: nil, only: nil) ⇒ Query
Returns a new instance of Query.
9 10 11 12 13 14 |
# File 'lib/mailscope/query.rb', line 9 def initialize(, mailbox: nil, term: nil, only: nil) @messages = @mailbox = mailbox.to_s.downcase.presence @term = term.to_s.strip.presence @only = only.to_s.presence end |
Instance Attribute Details
#mailbox ⇒ Object (readonly)
Returns the value of attribute mailbox.
7 8 9 |
# File 'lib/mailscope/query.rb', line 7 def mailbox @mailbox end |
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
7 8 9 |
# File 'lib/mailscope/query.rb', line 7 def @messages end |
#only ⇒ Object (readonly)
Returns the value of attribute only.
7 8 9 |
# File 'lib/mailscope/query.rb', line 7 def only @only end |
#term ⇒ Object (readonly)
Returns the value of attribute term.
7 8 9 |
# File 'lib/mailscope/query.rb', line 7 def term @term end |
Instance Method Details
#filtered? ⇒ Boolean
20 |
# File 'lib/mailscope/query.rb', line 20 def filtered? = !(mailbox.nil? && term.nil? && only.nil?) |
#results ⇒ Object
16 17 18 |
# File 'lib/mailscope/query.rb', line 16 def results @results ||= .select { |m| matches_mailbox?(m) && matches_only?(m) && matches_term?(m) } end |