Class: Basic101::LeftFunction

Inherits:
Function
  • Object
show all
Defined in:
lib/basic101/left_function.rb

Instance Method Summary collapse

Methods inherited from Function

#check_args

Instance Method Details

#call(runtime, args) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/basic101/left_function.rb', line 11

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

#nameObject



7
8
9
# File 'lib/basic101/left_function.rb', line 7

def name
  'LEFT$'
end