Class: FlatKit::Output::File
- Inherits:
-
FlatKit::Output
- Object
- FlatKit::Output
- FlatKit::Output::File
- Defined in:
- lib/flat_kit/output/file.rb
Overview
Internal: File output implementation
Instance Attribute Summary collapse
-
#io ⇒ Object
readonly
internal api method for testing purposes.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(obj) ⇒ File
constructor
A new instance of File.
- #name ⇒ Object
Methods inherited from FlatKit::Output
Methods included from DescendantTracker
#children, #find_child, #find_children, #inherited
Constructor Details
#initialize(obj) ⇒ File
Returns a new instance of File.
27 28 29 30 31 32 |
# File 'lib/flat_kit/output/file.rb', line 27 def initialize(obj) super() @path = Pathname.new(obj) path.dirname.mkpath @io = open_output(path) end |
Instance Attribute Details
#io ⇒ Object (readonly)
internal api method for testing purposes
14 15 16 |
# File 'lib/flat_kit/output/file.rb', line 14 def io @io end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
11 12 13 |
# File 'lib/flat_kit/output/file.rb', line 11 def path @path end |
Class Method Details
.handles?(obj) ⇒ Boolean
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/flat_kit/output/file.rb', line 16 def self.handles?(obj) return true if obj.instance_of?(Pathname) return false unless obj.instance_of?(String) # incase these get loaded in different orders return false if ::FlatKit::Output::IO.stdout?(obj) return false if ::FlatKit::Output::IO.stderr?(obj) true end |
Instance Method Details
#close ⇒ Object
38 39 40 |
# File 'lib/flat_kit/output/file.rb', line 38 def close @io.close end |
#name ⇒ Object
34 35 36 |
# File 'lib/flat_kit/output/file.rb', line 34 def name path.to_s end |