Class: Krackle::CLI
- Inherits:
-
Object
- Object
- Krackle::CLI
- Defined in:
- lib/krackle.rb
Instance Method Summary collapse
-
#initialize(args = ARGV) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Constructor Details
#initialize(args = ARGV) ⇒ CLI
Returns a new instance of CLI.
65 66 67 |
# File 'lib/krackle.rb', line 65 def initialize(args=ARGV) @expression, @path = args end |
Instance Method Details
#run ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'lib/krackle.rb', line 69 def run io = if @path File.open(@path, 'r') else $stdin.tty? ? raise("Specify a file path") : $stdin end Engine.new(YAML.load(io.read)).query(@expression).join("\n") end |