Sha256: 6bd7c1d8932ce0287503a321732a5ced8358f7275408fece22f1f84eebbef202

Contents?: true

Size: 413 Bytes

Versions: 3

Compression:

Stored size: 413 Bytes

Contents

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-0.4.0 lib/basic101/mid_function.rb
basic101-0.2.0 lib/basic101/mid_function.rb
basic101-0.1.0 lib/basic101/mid_function.rb