Class: LogfileInterval::LogfileSet
- Inherits:
-
Object
- Object
- LogfileInterval::LogfileSet
- Defined in:
- lib/logfile_interval/logfile_set.rb
Constant Summary collapse
- ORDER_VALID_VALUES =
[ :asc, :desc ]
Instance Attribute Summary collapse
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
Instance Method Summary collapse
- #each_line(&block) ⇒ Object
- #each_parsed_line(&block) ⇒ Object (also: #each)
- #first_parsed_line ⇒ Object (also: #first)
-
#initialize(filenames, parser, order = :desc, &file_time_finder_block) ⇒ LogfileSet
constructor
A new instance of LogfileSet.
- #ordered_filenames ⇒ Object
Constructor Details
#initialize(filenames, parser, order = :desc, &file_time_finder_block) ⇒ LogfileSet
Returns a new instance of LogfileSet.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/logfile_interval/logfile_set.rb', line 7 def initialize(filenames, parser, order = :desc, &file_time_finder_block) @parser = parser @filenames = filenames @order = order @file_time_finder_block = file_time_finder_block if block_given? reject_empty_files! reject_files_with_no_valid_line! raise ArgumentError, "invalid order value: #{@order}" unless ORDER_VALID_VALUES.include?(@order.to_sym) end |
Instance Attribute Details
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
3 4 5 |
# File 'lib/logfile_interval/logfile_set.rb', line 3 def parser @parser end |
Instance Method Details
#each_line(&block) ⇒ Object
36 37 38 39 |
# File 'lib/logfile_interval/logfile_set.rb', line 36 def each_line(&block) return enum_for(__method__) unless block_given? each_by_method(__method__, &block) end |
#each_parsed_line(&block) ⇒ Object Also known as: each
30 31 32 33 |
# File 'lib/logfile_interval/logfile_set.rb', line 30 def each_parsed_line(&block) return enum_for(__method__) unless block_given? each_by_method(__method__, &block) end |
#first_parsed_line ⇒ Object Also known as: first
41 42 43 |
# File 'lib/logfile_interval/logfile_set.rb', line 41 def first_parsed_line each_parsed_line.first end |
#ordered_filenames ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/logfile_interval/logfile_set.rb', line 19 def ordered_filenames time_for_files = time_for_files(existing_filenames) order_filenames_asc = time_for_files.to_a.sort_by { |arr| arr[1] }.map { |arr| arr[0] } case @order when :desc order_filenames_asc.reverse when :asc order_filenames_asc end end |