lib/code/object/string.rb in code-ruby-0.11.0 vs lib/code/object/string.rb in code-ruby-0.12.0
- old
+ new
@@ -1,15 +1,15 @@
# frozen_string_literal: true
class Code
class Object
class String < Object
- attr_reader :raw
-
- def initialize(string)
- string = string.raw if string.is_a?(String)
- @raw = string.to_s
+ def initialize(*args, **_kargs, &_block)
+ raw = args.first || Nothing.new
+ raw = raw.raw if raw.is_a?(Object)
+ @raw = raw.to_s
+ super
end
def self.name
"String"
end
@@ -23,11 +23,11 @@
case operator.to_s
when "&", "to_function"
sig(args)
code_to_function(**globals)
when "*"
- sig(args) { Number }
+ sig(args) { Integer | Decimal }
code_multiplication(value)
when "+"
sig(args) { Object }
code_plus(value)
when "downcase"
@@ -63,10 +63,10 @@
def code_reverse
String.new(raw.reverse)
end
def code_to_function(**globals)
- Code::Node::Code.new(
+ Node::Code.new(
[
{
function: {
parameters: [{ name: "_" }],
body: [