Sha256: 8fde1ca89226f10cf6475aa75dc56f20a299c4b71a630915b99f1282054ca182

Contents?: true

Size: 955 Bytes

Versions: 48

Compression:

Stored size: 955 Bytes

Contents

module Incline::Helpers
  ##
  # A "formatter" that simply collects formatted route data.
  class RouteHashFormatter

    ##
    # Creates a new hash formatter for the route inspector.
    def initialize
      @buffer = []
      @engine = ''
    end

    ##
    # Gets the resulting hash from the route inspector.
    def result
      @buffer
    end

    ##
    # Analyzes the section title to get the current engine name.
    def section_title(title)
      @engine = title.include?(' ') ? title.rpartition(' ')[2] : title
    end

    ##
    # Does nothing for this formatter.
    def header(routes)
      # no need for a header
    end

    ##
    # Does nothing for this formatter.
    def no_routes
      # no need to do anything here either.
    end

    ##
    # Adds the specified routes to the resulting hash.
    def section(routes)
      routes.each do |r|
        @buffer << r.symbolize_keys.merge(engine: @engine)
      end
    end

  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
incline-0.3.14 lib/incline/helpers/route_hash_formatter.rb
incline-0.3.13 lib/incline/helpers/route_hash_formatter.rb
incline-0.3.12 lib/incline/helpers/route_hash_formatter.rb
incline-0.3.11 lib/incline/helpers/route_hash_formatter.rb
incline-0.3.10 lib/incline/helpers/route_hash_formatter.rb
incline-0.3.9 lib/incline/helpers/route_hash_formatter.rb
incline-0.3.8 lib/incline/helpers/route_hash_formatter.rb
incline-0.3.7 lib/incline/helpers/route_hash_formatter.rb
incline-0.3.6 lib/incline/helpers/route_hash_formatter.rb
incline-0.3.5 lib/incline/helpers/route_hash_formatter.rb
incline-0.3.4 lib/incline/helpers/route_hash_formatter.rb
incline-0.3.3 lib/incline/helpers/route_hash_formatter.rb
incline-0.3.2 lib/incline/helpers/route_hash_formatter.rb
incline-0.3.1 lib/incline/helpers/route_hash_formatter.rb
incline-0.3.0 lib/incline/helpers/route_hash_formatter.rb
incline-0.2.36 lib/incline/helpers/route_hash_formatter.rb
incline-0.2.35 lib/incline/helpers/route_hash_formatter.rb
incline-0.2.34 lib/incline/helpers/route_hash_formatter.rb
incline-0.2.28 lib/incline/helpers/route_hash_formatter.rb
incline-0.2.27 lib/incline/helpers/route_hash_formatter.rb