Class: Incline::Helpers::RouteHashFormatter
- Inherits:
-
Object
- Object
- Incline::Helpers::RouteHashFormatter
- Defined in:
- lib/incline/helpers/route_hash_formatter.rb
Overview
A “formatter” that simply collects formatted route data.
Instance Method Summary collapse
-
#header(routes) ⇒ Object
Does nothing for this formatter.
-
#initialize ⇒ RouteHashFormatter
constructor
Creates a new hash formatter for the route inspector.
-
#no_routes ⇒ Object
Does nothing for this formatter.
-
#result ⇒ Object
Gets the resulting hash from the route inspector.
-
#section(routes) ⇒ Object
Adds the specified routes to the resulting hash.
-
#section_title(title) ⇒ Object
Analyzes the section title to get the current engine name.
Constructor Details
#initialize ⇒ RouteHashFormatter
Creates a new hash formatter for the route inspector.
8 9 10 11 |
# File 'lib/incline/helpers/route_hash_formatter.rb', line 8 def initialize @buffer = [] @engine = '' end |
Instance Method Details
#header(routes) ⇒ Object
Does nothing for this formatter.
27 28 29 |
# File 'lib/incline/helpers/route_hash_formatter.rb', line 27 def header(routes) # no need for a header end |
#no_routes ⇒ Object
Does nothing for this formatter.
33 34 35 |
# File 'lib/incline/helpers/route_hash_formatter.rb', line 33 def no_routes # no need to do anything here either. end |
#result ⇒ Object
Gets the resulting hash from the route inspector.
15 16 17 |
# File 'lib/incline/helpers/route_hash_formatter.rb', line 15 def result @buffer end |
#section(routes) ⇒ Object
Adds the specified routes to the resulting hash.
39 40 41 42 43 |
# 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) ⇒ Object
Analyzes the section title to get the current engine name.
21 22 23 |
# File 'lib/incline/helpers/route_hash_formatter.rb', line 21 def section_title(title) @engine = title.include?(' ') ? title.rpartition(' ')[2] : title end |