Class: RemLint::Rules::CalendarTextLimited

Inherits:
RemLint::Rule show all
Defined in:
lib/remlint/rules/calendar_text_limited.rb

Overview

A relative phrase that follows the reminder into a calendar box.

%"…%" marks the part of a body that belongs in a calendar. Outside the marks, text appears in Agenda Mode only. The distinction matters most for exactly the substitutions AdvanceWarningBody asks you to add:

REM 16 July ++10 MSG %"Jane's birthday%" %b.

In Agenda Mode that reads "Jane's birthday in 8 days' time". In a calendar it is printed in the box for 16 July, where "in 8 days' time" is not merely redundant but wrong -- the box already says which day it is.

So this is the second half of a pair: one rule asks for %b, this one asks you to fence it. Off by default, like its sibling, and for the same reason: a file that is never rendered as a calendar does not need it.

Constant Summary collapse

RELATIVE =
/%\*?[abcefghijkluv]/i
MARKER =
'%"'

Constants inherited from RemLint::Rule

RemLint::Rule::REGISTRY

Instance Attribute Summary

Attributes inherited from RemLint::Rule

#config, #document, #offenses

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RemLint::Rule

all, find, inherited, #initialize, rule_name, #rule_name, #run

Constructor Details

This class inherits a constructor from RemLint::Rule

Class Method Details

.default_severityObject



31
32
33
# File 'lib/remlint/rules/calendar_text_limited.rb', line 31

def self.default_severity
  "info"
end

.descriptionObject



35
36
37
# File 'lib/remlint/rules/calendar_text_limited.rb', line 35

def self.description
  "A relative-date substitution in a body with no %\" ... %\" calendar limit."
end

.enabled_by_default?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/remlint/rules/calendar_text_limited.rb', line 27

def self.enabled_by_default?
  false
end

Instance Method Details

#checkObject



39
40
41
42
43
44
45
46
47
# File 'lib/remlint/rules/calendar_text_limited.rb', line 39

def check
  document.code_commands.each do |command|
    trigger = document.trigger_for(command)

    if trigger.text_body?
      check_body(command, trigger)
    end
  end
end