Sha256: 0722e968c7aa5137d0ccb435a244abfd7bcd8f28bb4e02f2131b14671a0e7723

Contents?: true

Size: 444 Bytes

Versions: 3

Compression:

Stored size: 444 Bytes

Contents

# frozen_string_literal: true

module Basic101

  class MidFunction < Function

    def name
      'MID$'
    end

    def call(runtime, args)
      check_args args, [BasicString, BasicNumeric], [BasicNumeric]
      string, start, count = *args
      string = string.eval(runtime).to_string
      start = start.eval(runtime).to_integer
      count = count && count.eval(runtime).to_integer
      string.mid(start, *[count])
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
basic101-1.0.2 lib/basic101/mid_function.rb
basic101-1.0.1 lib/basic101/mid_function.rb
basic101-1.0.0 lib/basic101/mid_function.rb