class Gamefic::Scanner::Base

A base class for scanners that match tokens to entities.

Attributes

selection[R]

@return [Array<Entity>]

token[R]

@return [String]

Public Class Methods

new(selection, token) click to toggle source

@param selection [Array<Entity>] @param token [String]

# File lib/gamefic/scanner/base.rb, line 16
def initialize selection, token
  @selection = selection
  @token = token
end
scan(selection, token) click to toggle source

@param selection [Array<Entity>] @param token [String] @return [Result]

# File lib/gamefic/scanner/base.rb, line 29
def self.scan selection, token
  new(selection, token).scan
end

Public Instance Methods

scan() click to toggle source

@return [Result]

# File lib/gamefic/scanner/base.rb, line 22
def scan
  unmatched_result
end

Private Instance Methods

matched_result(matched, remainder) click to toggle source
# File lib/gamefic/scanner/base.rb, line 39
def matched_result matched, remainder
  Result.new(selection, token, matched, remainder, self.class)
end
unmatched_result() click to toggle source
# File lib/gamefic/scanner/base.rb, line 35
def unmatched_result
  Result.unmatched(selection, token, self.class)
end