Class: Appydave::Tools::Jump::Commands::Query
- Defined in:
- lib/appydave/tools/jump/commands/query.rb
Overview
Query command provides scriptable location lookup
Designed for pipeline use — default output is bare paths, one per line. Use –meta for structured JSON output.
Instance Attribute Summary collapse
-
#brand_filter ⇒ Object
readonly
Returns the value of attribute brand_filter.
-
#find_terms ⇒ Object
readonly
Returns the value of attribute find_terms.
-
#type_filter ⇒ Object
readonly
Returns the value of attribute type_filter.
Attributes inherited from Base
#config, #options, #path_validator
Instance Method Summary collapse
-
#initialize(config, **options) ⇒ Query
constructor
A new instance of Query.
- #run ⇒ Object
Constructor Details
#initialize(config, **options) ⇒ Query
Returns a new instance of Query.
23 24 25 26 27 28 |
# File 'lib/appydave/tools/jump/commands/query.rb', line 23 def initialize(config, **) super @find_terms = Array([:find]).map { |t| t.to_s.downcase.strip }.reject(&:empty?) @type_filter = normalize_option([:type]) @brand_filter = normalize_option([:brand]) end |
Instance Attribute Details
#brand_filter ⇒ Object (readonly)
Returns the value of attribute brand_filter.
21 22 23 |
# File 'lib/appydave/tools/jump/commands/query.rb', line 21 def brand_filter @brand_filter end |
#find_terms ⇒ Object (readonly)
Returns the value of attribute find_terms.
21 22 23 |
# File 'lib/appydave/tools/jump/commands/query.rb', line 21 def find_terms @find_terms end |
#type_filter ⇒ Object (readonly)
Returns the value of attribute type_filter.
21 22 23 |
# File 'lib/appydave/tools/jump/commands/query.rb', line 21 def type_filter @type_filter end |
Instance Method Details
#run ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/appydave/tools/jump/commands/query.rb', line 30 def run matches = config.locations.select { |loc| matches?(loc) } if matches.empty? return error_result( 'No locations found matching the given criteria', code: 'NOT_FOUND' ) end results = matches.map.with_index(1) do |location, index| location_to_result(location, index) end success_result( count: results.size, results: results ) end |