Class: Csvtool::Domain::Shared::OutputDestination
- Inherits:
-
Object
- Object
- Csvtool::Domain::Shared::OutputDestination
- Defined in:
- lib/csvtool/domain/shared/output_destination.rb
Instance Attribute Summary collapse
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #console? ⇒ Boolean
- #file? ⇒ Boolean
-
#initialize(mode:, path: nil) ⇒ OutputDestination
constructor
A new instance of OutputDestination.
Constructor Details
#initialize(mode:, path: nil) ⇒ OutputDestination
Returns a new instance of OutputDestination.
17 18 19 20 21 22 23 |
# File 'lib/csvtool/domain/shared/output_destination.rb', line 17 def initialize(mode:, path: nil) raise ArgumentError, "invalid output mode" unless i[console file].include?(mode) raise ArgumentError, "file output path cannot be empty" if mode == :file && path.to_s.empty? @mode = mode @path = path end |
Instance Attribute Details
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
7 8 9 |
# File 'lib/csvtool/domain/shared/output_destination.rb', line 7 def mode @mode end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/csvtool/domain/shared/output_destination.rb', line 7 def path @path end |
Class Method Details
.console ⇒ Object
9 10 11 |
# File 'lib/csvtool/domain/shared/output_destination.rb', line 9 def self.console new(mode: :console) end |
.file(path:) ⇒ Object
13 14 15 |
# File 'lib/csvtool/domain/shared/output_destination.rb', line 13 def self.file(path:) new(mode: :file, path: path) end |
Instance Method Details
#console? ⇒ Boolean
29 30 31 |
# File 'lib/csvtool/domain/shared/output_destination.rb', line 29 def console? @mode == :console end |
#file? ⇒ Boolean
25 26 27 |
# File 'lib/csvtool/domain/shared/output_destination.rb', line 25 def file? @mode == :file end |