class Keisan::AST::String

Attributes

content[R]

Public Class Methods

new(content) click to toggle source
# File lib/keisan/ast/string.rb, line 6
def initialize(content)
  @content = content
end

Public Instance Methods

+(other) click to toggle source
# File lib/keisan/ast/string.rb, line 14
def +(other)
  case other
  when String
    String.new(value + other.value)
  else
    raise Exceptions::TypeError.new("#{other}'s type is invalid, #{other.class}")
  end
end
equal(other) click to toggle source
Calls superclass method Keisan::AST::ConstantLiteral#equal
# File lib/keisan/ast/string.rb, line 31
def equal(other)
  other = other.to_node
  other.is_a?(AST::String) ? Boolean.new(value == other.value) : super
end
not_equal(other) click to toggle source
Calls superclass method Keisan::AST::ConstantLiteral#not_equal
# File lib/keisan/ast/string.rb, line 36
def not_equal(other)
  other = other.to_node
  other.is_a?(AST::String) ? Boolean.new(value != other.value) : super
end
to_s() click to toggle source
# File lib/keisan/ast/string.rb, line 23
def to_s
  if value =~ /\"/
    "\"#{value.gsub("\"", "\\\"")}\""
  else
    "\"#{value}\""
  end
end
value(context = nil) click to toggle source
# File lib/keisan/ast/string.rb, line 10
def value(context = nil)
  content
end