Sha256: d01e56bb7763c6c26aaad5aa51afa77a4cdb07ee18372947d27aa8d982e79621

Contents?: true

Size: 395 Bytes

Versions: 2

Compression:

Stored size: 395 Bytes

Contents

module Flexparser
  #
  # A semi-anonymous class used for building the node
  # structure.
  #
  class AnonymousParser
    extend ClassMethods

    def to_s
      return super if self.class.parsers.empty?
      to_h.to_s
    end

    def to_h
      self.class.parsers.each_with_object({}) do |parser, hash|
        hash[parser.name.to_sym] = public_send(parser.name)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
flexparser-1.0.3 lib/flexparser/anonymous_parser.rb
flexparser-1.0.2 lib/flexparser/anonymous_parser.rb