Class: RailsExportRoutes::Formatters::CSV
- Inherits:
-
Object
- Object
- RailsExportRoutes::Formatters::CSV
- Defined in:
- lib/rails_export_routes/formatters/csv.rb
Instance Method Summary collapse
-
#export_to_file(file) ⇒ Object
rubocop:disable Metrics/MethodLength.
-
#initialize(routes) ⇒ CSV
constructor
A new instance of CSV.
Constructor Details
#initialize(routes) ⇒ CSV
Returns a new instance of CSV.
9 10 11 |
# File 'lib/rails_export_routes/formatters/csv.rb', line 9 def initialize(routes) @routes = routes end |
Instance Method Details
#export_to_file(file) ⇒ Object
rubocop:disable Metrics/MethodLength
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rails_export_routes/formatters/csv.rb', line 13 def export_to_file(file) # rubocop:disable Metrics/MethodLength ::CSV.open(file, 'wb') do |csv| csv << %w[verb path controller action name constraints] @routes.each do |route| csv << [ route.verb, route.path_spec, route.controller, route.action, route.name, route.constraints.to_json ] end end end |