Class: Markdo::QueryCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/markdo/query_command.rb

Direct Known Subclasses

DateCommand, TagCommand

Instance Method Summary collapse

Methods inherited from Command

#initialize

Constructor Details

This class inherits a constructor from Markdo::Command

Instance Method Details

#run(string) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/markdo/query_command.rb', line 5

def run(string)
  regexp = Regexp.new(string, Regexp::IGNORECASE)

  matches = Dir.
    glob(markdown_glob).
    map { |path| File.readlines(path, encoding: 'UTF-8') }.
    flatten.
    grep(regexp)

  @stdout.puts(matches)
end