class Str
Public Class Methods
new(val=nil)
click to toggle source
# File lib/sdx/vm/datatypes.rb, line 249 def initialize(val=nil) if val != nil @internal = val end @fields = { "__as_str" => (NativeFnInternal.new (Proc.new do as_string end)), "__as_code_str" => (NativeFnInternal.new (Proc.new do as_code_string end)), "__add" => (NativeFnInternal.new (Proc.new do |other| add other[0] end)), "__mul" => (NativeFnInternal.new (Proc.new do |other| mul other[0] end)), "__eq" => (NativeFnInternal.new (lambda do |other| Bool.new @internal == other[0].internal end)), "__neq" => (NativeFnInternal.new (lambda do |other| Bool.new @internal != other[0].internal end)) } end
Public Instance Methods
add(other)
click to toggle source
# File lib/sdx/vm/datatypes.rb, line 283 def add(other) case other when Str else error "Cannot use Str + on #{other.class}" return nil end Str.new @internal + other.internal end
as_code_string()
click to toggle source
# File lib/sdx/vm/datatypes.rb, line 279 def as_code_string (Str.new @internal.dump) end
as_string()
click to toggle source
# File lib/sdx/vm/datatypes.rb, line 275 def as_string (Str.new @internal) end
mul(other)
click to toggle source
# File lib/sdx/vm/datatypes.rb, line 293 def mul(other) case other when Int else error "Cannot use Int * on #{other.class}" return nil end Str.new @internal * other.internal end