class Dentaku::AST::StringFunctions::Mid
Public Class Methods
max_param_count()
click to toggle source
# File lib/dentaku/ast/functions/string_functions.rb, line 68 def self.max_param_count 3 end
min_param_count()
click to toggle source
# File lib/dentaku/ast/functions/string_functions.rb, line 64 def self.min_param_count 3 end
new(*args)
click to toggle source
Calls superclass method
Dentaku::AST::Function::new
# File lib/dentaku/ast/functions/string_functions.rb, line 72 def initialize(*args) super @string, @offset, @length = *@args end
Public Instance Methods
value(context = {})
click to toggle source
# File lib/dentaku/ast/functions/string_functions.rb, line 77 def value(context = {}) string = @string.value(context).to_s offset = Dentaku::AST::Function.numeric(@offset.value(context)).to_i negative_argument_failure('MID', 'offset') if offset < 0 length = Dentaku::AST::Function.numeric(@length.value(context)).to_i negative_argument_failure('MID') if length < 0 string[offset - 1, length].to_s end