Class: RemLint::Rules::MoonPhaseArgument

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

Overview

Moon and season selectors outside their four-element sets.

moondate, moondatetime and moontime take a phase: 0 new, 1 first quarter, 2 full, 3 last quarter. soleq takes an event: 0 March equinox, 1 June solstice, 2 September equinox, 3 December solstice. Both are closed sets of four, so a literal 4 is always wrong and always visible without running anything.

Remind agrees -- moondate(4) is Number too high -- but says so on the day the line is reached, which for a moon reminder is the day it was supposed to fire.

Constant Summary collapse

PHASES =
{
  "moondate"     => "a moon phase",
  "moondatetime" => "a moon phase",
  "moontime"     => "a moon phase",
  "soleq"        => "a solstice or equinox",
}.freeze
MEANINGS =
{
  "a moon phase"          => "0 new, 1 first quarter, 2 full, 3 last quarter",
  "a solstice or equinox" => "0 March equinox, 1 June solstice, " \
                              "2 September equinox, 3 December solstice",
}.freeze
LIMIT =
3

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, enabled_by_default?, find, inherited, #initialize, rule_name, #rule_name, #run

Constructor Details

This class inherits a constructor from RemLint::Rule

Class Method Details

.default_severityObject



34
35
36
# File 'lib/remlint/rules/moon_phase_argument.rb', line 34

def self.default_severity
  "error"
end

.descriptionObject



38
39
40
# File 'lib/remlint/rules/moon_phase_argument.rb', line 38

def self.description
  "A moon phase or solstice selector outside the four values it accepts."
end

Instance Method Details

#checkObject



42
43
44
45
46
47
48
# File 'lib/remlint/rules/moon_phase_argument.rb', line 42

def check
  document.logical_lines.each_with_index do |logical_line, index|
    if document.commands[index].code?
      check_line(logical_line)
    end
  end
end