Class: RapidDiffs::Viewers::Text::LineNumberComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- RapidDiffs::Viewers::Text::LineNumberComponent
- Defined in:
- app/components/rapid_diffs/viewers/text/line_number_component.rb
Instance Method Summary collapse
- #change_type ⇒ Object
-
#initialize(line:, line_id:, position:) ⇒ LineNumberComponent
constructor
A new instance of LineNumberComponent.
- #label ⇒ Object
- #line_number ⇒ Object
- #visible? ⇒ Boolean
Constructor Details
#initialize(line:, line_id:, position:) ⇒ LineNumberComponent
Returns a new instance of LineNumberComponent.
7 8 9 10 11 |
# File 'app/components/rapid_diffs/viewers/text/line_number_component.rb', line 7 def initialize(line:, line_id:, position:) @line = line @line_id = line_id @position = position end |
Instance Method Details
#change_type ⇒ Object
17 18 19 20 21 22 23 |
# File 'app/components/rapid_diffs/viewers/text/line_number_component.rb', line 17 def change_type return unless @line return 'meta' if @line. return 'added' if @line.added? 'removed' if @line.removed? end |
#label ⇒ Object
25 26 27 28 29 30 |
# File 'app/components/rapid_diffs/viewers/text/line_number_component.rb', line 25 def label return s_('RapidDiffs|Removed line %d') % line_number if @line.removed? return s_('RapidDiffs|Added line %d') % line_number if @line.added? s_('RapidDiffs|Line %d') % line_number end |
#line_number ⇒ Object
13 14 15 |
# File 'app/components/rapid_diffs/viewers/text/line_number_component.rb', line 13 def line_number @position == :old ? @line.old_pos : @line.new_pos end |
#visible? ⇒ Boolean
32 33 34 35 36 37 38 39 40 |
# File 'app/components/rapid_diffs/viewers/text/line_number_component.rb', line 32 def visible? return false unless @line && !@line. case @position when :old then !@line.added? when :new then !@line.removed? else false end end |