Sha256: 881f555219035c794dae7c5d6c9b525392f75c9a33fde422891737afb8719409

Contents?: true

Size: 569 Bytes

Versions: 4

Compression:

Stored size: 569 Bytes

Contents

class Code
  class Node
    class String < Node
      def initialize(string)
        if string.to_s.blank?
          @string = []
        elsif string.is_a?(Array)
          @string = string.map do |component|
            ::Code::Node::StringComponent.new(component)
          end
        else
          @string = [::Code::Node::StringCharacters.new(string)]
        end
      end

      def evaluate(**args)
        string = @string.map { |component| component.evaluate(**args) }.map(&:to_s).join
        ::Code::Object::String.new(string)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
template-ruby-0.3.1 lib/code/node/string.rb
code-ruby-0.3.1 lib/code/node/string.rb
template-ruby-0.3.0 lib/code/node/string.rb
code-ruby-0.3.0 lib/code/node/string.rb