Class: Rouge::FileReader
- Inherits:
-
Object
- Object
- Rouge::FileReader
- Defined in:
- lib/rouge/cli.rb
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
Instance Method Summary collapse
- #file ⇒ Object
-
#initialize(input) ⇒ FileReader
constructor
A new instance of FileReader.
- #read ⇒ Object
Constructor Details
#initialize(input) ⇒ FileReader
Returns a new instance of FileReader.
9 10 11 |
# File 'lib/rouge/cli.rb', line 9 def initialize(input) @input = input end |
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
8 9 10 |
# File 'lib/rouge/cli.rb', line 8 def input @input end |
Instance Method Details
#file ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rouge/cli.rb', line 13 def file case input when '-' $stdin when String File.new(input) when ->(i){ i.respond_to? :read } input end end |
#read ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rouge/cli.rb', line 24 def read @read ||= begin file.read rescue => e $stderr.puts "unable to open #{input}: #{e.}" exit 1 ensure file.close end end |