Class: RemLint::Command
- Inherits:
-
Struct
- Object
- Struct
- RemLint::Command
- Defined in:
- lib/remlint/command.rb
Overview
A classified logical line: which keyword opens it, and what follows.
keyword is nil for three different things, and rules must not confuse
them, so ask rather than test for nil:
blank? nothing but whitespace
comment? opens with `#` or `;`
implicit? a trigger with the `REM` left off -- `1 Nov ++12 MSG ...`,
which the manual explicitly allows and which is the ordinary
way to write a reminder
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#keyword ⇒ Object
Returns the value of attribute keyword.
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#logical_line ⇒ Object
Returns the value of attribute logical_line.
-
#word ⇒ Object
Returns the value of attribute word.
Instance Method Summary collapse
-
#args_offset ⇒ Object
Where
argsbegins intext. - #blank? ⇒ Boolean
-
#code? ⇒ Boolean
Blank lines and comments are not commands at all.
- #comment? ⇒ Boolean
-
#implicit? ⇒ Boolean
A command line that opens with no recognisable keyword.
- #keyword?(*names) ⇒ Boolean
-
#keyword_column ⇒ Object
The column, 1-based, where the keyword itself starts.
- #last_line ⇒ Object
- #line ⇒ Object
- #text ⇒ Object
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args
17 18 19 |
# File 'lib/remlint/command.rb', line 17 def args @args end |
#keyword ⇒ Object
Returns the value of attribute keyword
17 18 19 |
# File 'lib/remlint/command.rb', line 17 def keyword @keyword end |
#kind ⇒ Object
Returns the value of attribute kind
17 18 19 |
# File 'lib/remlint/command.rb', line 17 def kind @kind end |
#logical_line ⇒ Object
Returns the value of attribute logical_line
17 18 19 |
# File 'lib/remlint/command.rb', line 17 def logical_line @logical_line end |
#word ⇒ Object
Returns the value of attribute word
17 18 19 |
# File 'lib/remlint/command.rb', line 17 def word @word end |
Instance Method Details
#args_offset ⇒ Object
Where args begins in text. args is always a suffix of text, so a
rule that found something at offset N in args can hand
args_offset + N to LogicalLine#position_at and get a real file position.
28 29 30 |
# File 'lib/remlint/command.rb', line 28 def args_offset text.length - args.length end |
#blank? ⇒ Boolean
44 45 46 |
# File 'lib/remlint/command.rb', line 44 def blank? kind == :blank end |
#code? ⇒ Boolean
Blank lines and comments are not commands at all.
59 60 61 |
# File 'lib/remlint/command.rb', line 59 def code? kind == :keyword || kind == :implicit end |
#comment? ⇒ Boolean
48 49 50 |
# File 'lib/remlint/command.rb', line 48 def comment? kind == :comment end |
#implicit? ⇒ Boolean
A command line that opens with no recognisable keyword. Remind reads it
as a bare trigger with an implicit REM.
54 55 56 |
# File 'lib/remlint/command.rb', line 54 def implicit? kind == :implicit end |
#keyword?(*names) ⇒ Boolean
63 64 65 |
# File 'lib/remlint/command.rb', line 63 def keyword?(*names) !keyword.nil? && names.map(&:upcase).include?(keyword.name) end |
#keyword_column ⇒ Object
The column, 1-based, where the keyword itself starts.
68 69 70 |
# File 'lib/remlint/command.rb', line 68 def keyword_column (text.index(/\S/) || 0) + 1 end |
#last_line ⇒ Object
36 37 38 |
# File 'lib/remlint/command.rb', line 36 def last_line logical_line.last_line end |
#line ⇒ Object
32 33 34 |
# File 'lib/remlint/command.rb', line 32 def line logical_line.line end |
#text ⇒ Object
40 41 42 |
# File 'lib/remlint/command.rb', line 40 def text logical_line.text end |