Class: RRSE::Command::PipeQuery
- Inherits:
-
Object
- Object
- RRSE::Command::PipeQuery
- Defined in:
- lib/rrse/pipe-query-command.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(dir) ⇒ PipeQuery
constructor
A new instance of PipeQuery.
- #options ⇒ Object
- #run(argv) ⇒ Object
Constructor Details
#initialize(dir) ⇒ PipeQuery
Returns a new instance of PipeQuery.
10 11 12 13 |
# File 'lib/rrse/pipe-query-command.rb', line 10 def initialize(dir) @dir = dir @db = nil end |
Class Method Details
.short_description ⇒ Object
6 7 8 |
# File 'lib/rrse/pipe-query-command.rb', line 6 def self.short_description "invoke query process" end |
Instance Method Details
#options ⇒ Object
15 16 17 18 19 20 |
# File 'lib/rrse/pipe-query-command.rb', line 15 def opts = OptionParser.new opts. = "Usage: rrse [global-options] pipe-query" opts.on("-s SEP", "separator"){|sep| @separator = sep } opts end |
#run(argv) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rrse/pipe-query-command.rb', line 22 def run(argv) .parse!(argv) @db = RRSE::Database.new(@dir, @separator) while line = gets query_type, query_str = line.strip.split(/\s+/) case query_type when "full-name" puts @db.query_full_name(query_str) when "instance-method" puts @db.query_instance_method(query_str) when "toplevel-method" puts @db.query_toplevel_method(query_str) when "quit" return else STDERR.puts "unknown query type: #{query_type}" end end end |