Class: Tcepsni::Vendor::StringScanner

Inherits:
Object
  • Object
show all
Defined in:
lib/tcepsni/vendor/string_scanner.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pos:, total:, scanned:, rest:) ⇒ StringScanner

Returns a new instance of StringScanner.



6
7
8
9
10
11
# File 'lib/tcepsni/vendor/string_scanner.rb', line 6

def initialize(pos:, total:, scanned:, rest:)
  @pos     = pos
  @total   = total
  @scanned = scanned
  @rest    = rest
end

Instance Attribute Details

#posObject (readonly)

Returns the value of attribute pos.



4
5
6
# File 'lib/tcepsni/vendor/string_scanner.rb', line 4

def pos
  @pos
end

#restObject (readonly)

Returns the value of attribute rest.



4
5
6
# File 'lib/tcepsni/vendor/string_scanner.rb', line 4

def rest
  @rest
end

#scannedObject (readonly)

Returns the value of attribute scanned.



4
5
6
# File 'lib/tcepsni/vendor/string_scanner.rb', line 4

def scanned
  @scanned
end

#totalObject (readonly)

Returns the value of attribute total.



4
5
6
# File 'lib/tcepsni/vendor/string_scanner.rb', line 4

def total
  @total
end

Class Method Details

.dependenciesObject



31
32
33
# File 'lib/tcepsni/vendor/string_scanner.rb', line 31

def self.dependencies
  []
end

.object?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/tcepsni/vendor/string_scanner.rb', line 35

def self.object?
  true
end

.parse(parser) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/tcepsni/vendor/string_scanner.rb', line 13

def self.parse(parser)
  pos = parser.pos
  parser.skip('StringScanner ')   and
    pos = parser.parse_integer    and
    parser.skip('/')              and
    total = parser.parse_integer  and
    parser.skip(' ')              and
    scanned = parser.parse_string and
    parser.skip(' @ ')            and
    rest = parser.parse_string    and
    parser.skip('>')              and
    Tcepsni::Vendor::StringScanner.new(pos:, total:, scanned:, rest:) or
    begin
      parser.pos = pos
      nil
    end
end