Sha256: 2f33fb1d57a931fa0caaf15747c9d53d423bfe53ad6c5b43f2a784102e2f4c67

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

module GrapeDoc
  class ApiDocParts

    module Parser
      class << self

        def parse(object)
          case object

            when Array
              object.map{|e|
                case e
                  when Array
                    e.dup

                  else
                    self.format_parse(*e)

                end
              }

            else
              # self.format_parse(object)
              object

          end
        end

        def format_parse(text,*args)
          text = text.dup.to_s
          args.each do |command|
            case command.to_s.downcase

              when /^bold/
                text.replace("*#{text}*")

              when /^italic/
                text.replace("__#{text}__")

              when /^underlined/
                text.replace("+#{text}+")

              when /^superscript/
                text.replace("^#{text}^")

            end
          end;return text

        end

        def typer(obj)
          case obj

            when Array
              obj.map(&:typer)

            when Hash
              obj.reduce({}){|m,o| m.merge!(o[0] => typer(o[1]) ) ;m}

            when Class,Module
              obj

            else
              obj.class

          end

        end

      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
grape-doc-0.3.0 lib/grape/doc/doc_class/parser.rb