Class: Kubetailrb::Reader::FileReader
- Inherits:
-
Object
- Object
- Kubetailrb::Reader::FileReader
- Includes:
- Validated
- Defined in:
- lib/kubetailrb/reader/file_reader.rb
Overview
Read file content
Instance Attribute Summary collapse
-
#filepath ⇒ Object
readonly
Returns the value of attribute filepath.
-
#last_nb_lines ⇒ Object
readonly
Returns the value of attribute last_nb_lines.
Instance Method Summary collapse
-
#follow? ⇒ Boolean
NOTE: Is there something like ‘attr_reader` but for boolean? Nope, Ruby does not know if a variable is a boolean or not.
-
#initialize(filepath:, last_nb_lines:, follow:) ⇒ FileReader
constructor
A new instance of FileReader.
- #read ⇒ Object
Methods included from Validated
#raise_if_blank, #raise_if_nil, #validate_boolean, #validate_last_nb_lines
Constructor Details
#initialize(filepath:, last_nb_lines:, follow:) ⇒ FileReader
Returns a new instance of FileReader.
13 14 15 16 17 18 19 |
# File 'lib/kubetailrb/reader/file_reader.rb', line 13 def initialize(filepath:, last_nb_lines:, follow:) @filepath = filepath @last_nb_lines = last_nb_lines @follow = follow validate end |
Instance Attribute Details
#filepath ⇒ Object (readonly)
Returns the value of attribute filepath.
11 12 13 |
# File 'lib/kubetailrb/reader/file_reader.rb', line 11 def filepath @filepath end |
#last_nb_lines ⇒ Object (readonly)
Returns the value of attribute last_nb_lines.
11 12 13 |
# File 'lib/kubetailrb/reader/file_reader.rb', line 11 def last_nb_lines @last_nb_lines end |
Instance Method Details
#follow? ⇒ Boolean
NOTE: Is there something like ‘attr_reader` but for boolean? Nope, Ruby does not know if a variable is a boolean or not. So it cannot create a dedicated method for those booleans.
29 30 31 |
# File 'lib/kubetailrb/reader/file_reader.rb', line 29 def follow? @follow end |
#read ⇒ Object
21 22 23 24 |
# File 'lib/kubetailrb/reader/file_reader.rb', line 21 def read # naive_read read_with_fd end |