Class: Rouge::CLI::Guess
- Inherits:
-
Rouge::CLI
- Object
- Rouge::CLI
- Rouge::CLI::Guess
- Defined in:
- lib/rouge/cli.rb
Instance Attribute Summary collapse
-
#input_file ⇒ Object
readonly
Returns the value of attribute input_file.
-
#input_source ⇒ Object
readonly
Returns the value of attribute input_source.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(opts) ⇒ Guess
constructor
A new instance of Guess.
- #lexers ⇒ Object
- #run ⇒ Object
Methods inherited from Rouge::CLI
class_from_arg, doc, error!, #error!, normalize_syntax
Constructor Details
#initialize(opts) ⇒ Guess
Returns a new instance of Guess.
394 395 396 397 |
# File 'lib/rouge/cli.rb', line 394 def initialize(opts) @input_file = opts[:input_file] || '-' @input_source = FileReader.new(@input_file).read end |
Instance Attribute Details
#input_file ⇒ Object (readonly)
Returns the value of attribute input_file.
392 393 394 |
# File 'lib/rouge/cli.rb', line 392 def input_file @input_file end |
#input_source ⇒ Object (readonly)
Returns the value of attribute input_source.
392 393 394 |
# File 'lib/rouge/cli.rb', line 392 def input_source @input_source end |
Class Method Details
.desc ⇒ Object
384 385 386 |
# File 'lib/rouge/cli.rb', line 384 def self.desc "guess the languages of file" end |
.parse(args) ⇒ Object
388 389 390 |
# File 'lib/rouge/cli.rb', line 388 def self.parse(args) new(input_file: args.shift) end |
Instance Method Details
#lexers ⇒ Object
399 400 401 402 403 404 |
# File 'lib/rouge/cli.rb', line 399 def lexers Lexer.guesses( filename: input_file, source: input_source, ) end |
#run ⇒ Object
406 407 408 409 410 |
# File 'lib/rouge/cli.rb', line 406 def run lexers.each do |l| puts "{ tag: #{l.tag.inspect}, title: #{l.title.inspect}, desc: #{l.desc.inspect} }" end end |