Sha256: ab49cdf3620210491d567222fd4f5347328a3544cfcbf98f99a90299d9650b12

Contents?: true

Size: 675 Bytes

Versions: 1

Compression:

Stored size: 675 Bytes

Contents

module FbErrorMachine
  class ErrorWriter

    def self.write_errors(attrs)
      type = attrs.delete(:type)
      errors = attrs[:errors]

      store_path = "lib/fb_error_machine/#{type}_api_errors.yml"
      File.open(store_path, 'w') {|f| f.write errors.to_yaml }
    end

    def self.find_error_code(row)
      sanitize(row.tds.first.inner_html)
    end

    def self.find_description(row)
      dirty_html = row.tds.to_a[1].inner_html
      sanitize(dirty_html)
    end

    def self.find_instructions(row)
      sanitize(row.tds[2].inner_html)
    end

    def self.sanitize(html)
      Sanitize.fragment(html).strip.gsub("\n", "").gsub("  ", " ")
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fb_error_machine-0.1.1 lib/fb_error_machine/error_writer.rb