Class: FlatKit::Output::File
- Inherits:
-
FlatKit::Output
- Object
- FlatKit::Output
- FlatKit::Output::File
- Defined in:
- lib/flat_kit/output/file.rb
Instance Attribute Summary collapse
-
#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.
-
#io ⇒ Object
internal api method for testing purposes.
- #name ⇒ Object
Methods inherited from FlatKit::Output
Methods included from DescendantTracker
#children, #find_child, #inherited
Constructor Details
#initialize(obj) ⇒ File
Returns a new instance of File.
19 20 21 22 23 |
# File 'lib/flat_kit/output/file.rb', line 19 def initialize(obj) @path = Pathname.new(obj) path.dirname.mkpath @io = open_output(path) end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/flat_kit/output/file.rb', line 6 def path @path end |
Class Method Details
.handles?(obj) ⇒ Boolean
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/flat_kit/output/file.rb', line 8 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.is_stdout?(obj) return false if ::FlatKit::Output::IO.is_stderr?(obj) return true end |
Instance Method Details
#close ⇒ Object
29 30 31 |
# File 'lib/flat_kit/output/file.rb', line 29 def close @io.close end |
#io ⇒ Object
internal api method for testing purposes
34 35 36 |
# File 'lib/flat_kit/output/file.rb', line 34 def io @io end |
#name ⇒ Object
25 26 27 |
# File 'lib/flat_kit/output/file.rb', line 25 def name path.to_s end |