Class: Gamefic::Scanner::Result
- Inherits:
-
Object
- Object
- Gamefic::Scanner::Result
- Defined in:
- lib/gamefic/scanner/result.rb
Overview
The result of an attempt to scan objects against a token in a Scanner. It provides an array of matching objects, the text that matched them, and the text that remains unmatched.
Instance Attribute Summary collapse
-
#matched ⇒ Array<Entity>, String
(also: #match)
readonly
The matched objects.
-
#processor ⇒ Object
readonly
Returns the value of attribute processor.
-
#remainder ⇒ String
readonly
The remaining (unmatched) portion of the token.
-
#scanned ⇒ Array<Entity>, ...
readonly
The scanned objects.
-
#token ⇒ String
readonly
The scanned token.
Class Method Summary collapse
Instance Method Summary collapse
- #filter(*args) ⇒ Object
-
#initialize(scanned, token, matched, remainder, processor) ⇒ Result
constructor
A new instance of Result.
-
#strictness ⇒ Integer
The strictness of the scanner that produced this result.
Constructor Details
#initialize(scanned, token, matched, remainder, processor) ⇒ Result
33 34 35 36 37 38 39 |
# File 'lib/gamefic/scanner/result.rb', line 33 def initialize scanned, token, matched, remainder, processor @scanned = scanned @token = token @matched = matched @remainder = remainder @processor = processor end |
Instance Attribute Details
#matched ⇒ Array<Entity>, String (readonly) Also known as: match
The matched objects
23 24 25 |
# File 'lib/gamefic/scanner/result.rb', line 23 def matched @matched end |
#processor ⇒ Object (readonly)
Returns the value of attribute processor.
31 32 33 |
# File 'lib/gamefic/scanner/result.rb', line 31 def processor @processor end |
#remainder ⇒ String (readonly)
The remaining (unmatched) portion of the token
29 30 31 |
# File 'lib/gamefic/scanner/result.rb', line 29 def remainder @remainder end |
#scanned ⇒ Array<Entity>, ... (readonly)
The scanned objects
13 14 15 |
# File 'lib/gamefic/scanner/result.rb', line 13 def scanned @scanned end |
#token ⇒ String (readonly)
The scanned token
18 19 20 |
# File 'lib/gamefic/scanner/result.rb', line 18 def token @token end |
Class Method Details
.unmatched(scanned, token, processor) ⇒ Object
58 59 60 |
# File 'lib/gamefic/scanner/result.rb', line 58 def self.unmatched scanned, token, processor new(scanned, token, [], token, processor) end |
Instance Method Details
#filter(*args) ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/gamefic/scanner/result.rb', line 48 def filter *args Scanner::Result.new( scanned, token, match.that_are(*args), remainder, processor ) end |
#strictness ⇒ Integer
The strictness of the scanner that produced this result.
44 45 46 |
# File 'lib/gamefic/scanner/result.rb', line 44 def strictness @strictness ||= Scanner.strictness(processor) end |