class Rouge::FileReader

Attributes

input[R]

Public Class Methods

new(input) click to toggle source
# File lib/rouge/cli.rb, line 9
def initialize(input)
  @input = input
end

Public Instance Methods

file() click to toggle source
# File lib/rouge/cli.rb, line 13
def file
  case input
  when '-'
    IO.new($stdin.fileno, 'rt:bom|utf-8')
  when String
    File.new(input, 'rt:bom|utf-8')
  when ->(i){ i.respond_to? :read }
    input
  end
end
read() click to toggle source
# File lib/rouge/cli.rb, line 24
def read
  @read ||= begin
    file.read
  rescue => e
    $stderr.puts "unable to open #{input}: #{e.message}"
    exit 1
  ensure
    file.close
  end
end