Class: Opalla::Util::JsFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/opalla/util.rb

Instance Method Summary collapse

Constructor Details

#initializeJsFormatter

Returns a new instance of JsFormatter.



13
14
15
# File 'lib/opalla/util.rb', line 13

def initialize
  @buffer = []
end

Instance Method Details

#header(routes) ⇒ Object



32
# File 'lib/opalla/util.rb', line 32

def header(routes); end

#resultObject



17
18
19
# File 'lib/opalla/util.rb', line 17

def result
  @buffer
end

#section(routes) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/opalla/util.rb', line 21

def section(routes)
  @buffer = routes.each_with_object({}) do |r, memo|
    path = r[:path].gsub(/\(.:format\)/, '')
    memo[r[:name]] = {
      verb: r[:verb],
      path: path,
      reqs: r[:reqs]
    }
  end
end