class Incline::Helpers::RouteHashFormatter

A “formatter” that simply collects formatted route data.

Public Class Methods

new() click to toggle source

Creates a new hash formatter for the route inspector.

# File lib/incline/helpers/route_hash_formatter.rb, line 8
def initialize
  @buffer = []
  @engine = ''
end

Public Instance Methods

header(routes) click to toggle source

Does nothing for this formatter.

# File lib/incline/helpers/route_hash_formatter.rb, line 27
def header(routes)
  # no need for a header
end
no_routes() click to toggle source

Does nothing for this formatter.

# File lib/incline/helpers/route_hash_formatter.rb, line 33
def no_routes
  # no need to do anything here either.
end
result() click to toggle source

Gets the resulting hash from the route inspector.

# File lib/incline/helpers/route_hash_formatter.rb, line 15
def result
  @buffer
end
section(routes) click to toggle source

Adds the specified routes to the resulting hash.

# File lib/incline/helpers/route_hash_formatter.rb, line 39
def section(routes)
  routes.each do |r|
    @buffer << r.symbolize_keys.merge(engine: @engine)
  end
end
section_title(title) click to toggle source

Analyzes the section title to get the current engine name.

# File lib/incline/helpers/route_hash_formatter.rb, line 21
def section_title(title)
  @engine = title.include?(' ') ? title.rpartition(' ')[2] : title
end