Class: Str
Instance Attribute Summary
Attributes inherited from DataType
Instance Method Summary collapse
- #add(other) ⇒ Object
- #as_code_string ⇒ Object
- #as_string ⇒ Object
-
#initialize(val = nil) ⇒ Str
constructor
A new instance of Str.
- #mul(other) ⇒ Object
Constructor Details
#initialize(val = nil) ⇒ Str
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/sdx/vm/datatypes.rb', line 178 def initialize(val=nil) if val != nil @internal = val end @fields = { "__as_string" => (NativeFnInternal.new (Proc.new do as_string end)), "__as_code_string" => (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 |
Instance Method Details
#add(other) ⇒ Object
212 213 214 |
# File 'lib/sdx/vm/datatypes.rb', line 212 def add(other) Str.new @internal + other.internal end |
#as_code_string ⇒ Object
208 209 210 |
# File 'lib/sdx/vm/datatypes.rb', line 208 def as_code_string (Str.new @internal.dump) end |
#as_string ⇒ Object
204 205 206 |
# File 'lib/sdx/vm/datatypes.rb', line 204 def as_string (Str.new @internal) end |
#mul(other) ⇒ Object
216 217 218 |
# File 'lib/sdx/vm/datatypes.rb', line 216 def mul(other) Str.new @internal * other.internal end |