Class: Text::Gen::Segment::Number

Inherits:
Object
  • Object
show all
Defined in:
lib/text/gen/segment/number.rb

Constant Summary collapse

NUMBER_MATCHER =
/([+-]?\d+)/

Class Method Summary collapse

Class Method Details

.scan(scanner) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/text/gen/segment/number.rb', line 9

def scan(scanner)
  str = scanner.scan(NUMBER_MATCHER)
  return unless str

  {
    "type" => "constant",
    "text" => str,
    "value" => 0,
    "multiplier" => Integer(str)
  }
end