Class: LawSchoolOutcomes::Section

Inherits:
Object
  • Object
show all
Defined in:
lib/law_school_outcomes/employment_summary_report/section.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(report:, header_content:, number_of_lines:) ⇒ Section

Returns a new instance of Section.



5
6
7
8
9
# File 'lib/law_school_outcomes/employment_summary_report/section.rb', line 5

def initialize(report:, header_content:, number_of_lines:)
  @report = report
  @header_content = header_content
  @number_of_lines = number_of_lines
end

Instance Attribute Details

#header_contentObject (readonly)

Returns the value of attribute header_content.



3
4
5
# File 'lib/law_school_outcomes/employment_summary_report/section.rb', line 3

def header_content
  @header_content
end

#number_of_linesObject (readonly)

Returns the value of attribute number_of_lines.



3
4
5
# File 'lib/law_school_outcomes/employment_summary_report/section.rb', line 3

def number_of_lines
  @number_of_lines
end

#reportObject (readonly)

Returns the value of attribute report.



3
4
5
# File 'lib/law_school_outcomes/employment_summary_report/section.rb', line 3

def report
  @report
end

Instance Method Details

#first_line_indexObject



11
12
13
# File 'lib/law_school_outcomes/employment_summary_report/section.rb', line 11

def first_line_index
  report.lines.each_with_index.find{|line, i| line.include?(header_content)}.last
end

#last_line_indexObject



15
16
17
# File 'lib/law_school_outcomes/employment_summary_report/section.rb', line 15

def last_line_index
  first_line_index + number_of_lines
end

#linesObject



19
20
21
# File 'lib/law_school_outcomes/employment_summary_report/section.rb', line 19

def lines
  report.lines[first_line_index .. last_line_index]
end