Class: Kubetailrb::Cmd::File
- Inherits:
-
Object
- Object
- Kubetailrb::Cmd::File
- Defined in:
- lib/kubetailrb/cmd/file.rb
Overview
Command to read a file.
Constant Summary collapse
- DEFAULT_NB_LINES =
10- DEFAULT_FOLLOW =
false- FILE_FLAG =
'--file'- TAIL_FLAG =
'--tail'
Instance Attribute Summary collapse
-
#reader ⇒ Object
readonly
Returns the value of attribute reader.
Class Method Summary collapse
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(filepath:, last_nb_lines: DEFAULT_NB_LINES, follow: DEFAULT_FOLLOW) ⇒ File
constructor
A new instance of File.
Constructor Details
#initialize(filepath:, last_nb_lines: DEFAULT_NB_LINES, follow: DEFAULT_FOLLOW) ⇒ File
Returns a new instance of File.
15 16 17 |
# File 'lib/kubetailrb/cmd/file.rb', line 15 def initialize(filepath:, last_nb_lines: DEFAULT_NB_LINES, follow: DEFAULT_FOLLOW) @reader = Kubetailrb::Reader::FileReader.new(filepath: filepath, last_nb_lines: last_nb_lines, follow: follow) end |
Instance Attribute Details
#reader ⇒ Object (readonly)
Returns the value of attribute reader.
13 14 15 |
# File 'lib/kubetailrb/cmd/file.rb', line 13 def reader @reader end |
Class Method Details
.applicable?(*args) ⇒ Boolean
28 29 30 |
# File 'lib/kubetailrb/cmd/file.rb', line 28 def applicable?(*args) args.include?(FILE_FLAG) end |
.create(*args) ⇒ Object
24 25 26 |
# File 'lib/kubetailrb/cmd/file.rb', line 24 def create(*args) new(filepath: parse_filepath(*args), last_nb_lines: parse_nb_lines(*args), follow: parse_follow(*args)) end |
Instance Method Details
#execute ⇒ Object
19 20 21 |
# File 'lib/kubetailrb/cmd/file.rb', line 19 def execute @reader.read end |