Class: RRSE::Command::Query
- Inherits:
-
Object
- Object
- RRSE::Command::Query
- Defined in:
- lib/rrse/query-command.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(dir) ⇒ Query
constructor
A new instance of Query.
- #load_table(path) ⇒ Object
- #run(argv) ⇒ Object
Constructor Details
#initialize(dir) ⇒ Query
Returns a new instance of Query.
8 9 10 11 12 |
# File 'lib/rrse/query-command.rb', line 8 def initialize(dir) @dir = dir @table = load_table(@dir.join("table")) @index_table = load_table(@dir.join("index_table")) end |
Class Method Details
.short_description ⇒ Object
4 5 6 |
# File 'lib/rrse/query-command.rb', line 4 def self.short_description "query method parameters from method name" end |
Instance Method Details
#load_table(path) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rrse/query-command.rb', line 14 def load_table(path) table = Hash.new File.open(path) do |f| f.each_line do |line| line.chomp! key, *entries = line.split(/\t/) table[key] = entries end end table end |
#run(argv) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rrse/query-command.rb', line 26 def run(argv) query = argv.shift method_specs = @index_table[query] return unless method_specs method_specs.each do |spec| @table[spec].each do |param| puts "#{spec}#{param}" end end end |