Sha256: a185f4d84f7a28c063127c6985957cace73cc2a9fc59e154f5bbca274b6dd809

Contents?: true

Size: 420 Bytes

Versions: 1

Compression:

Stored size: 420 Bytes

Contents

# frozen_string_literal: true

require 'json'

module Cosensee
  # serializer for brackets
  module BracketSerializer
    def to_s
      content.map(&:to_s).join
    end

    def to_obj
      unparsed = content.map do |elem|
        if elem.is_a?(String)
          elem
        else
          elem.to_obj
        end
      end

      "[#{unparsed}]"
    end

    def to_json(*)
      to_obj.to_json(*)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cosensee-0.8.0 lib/cosensee/bracket_serializer.rb