Class: FbErrorMachine::ErrorWriter
- Inherits:
-
Object
- Object
- FbErrorMachine::ErrorWriter
- Defined in:
- lib/fb_error_machine/error_writer.rb
Class Method Summary collapse
- .find_description(row) ⇒ Object
- .find_error_code(row) ⇒ Object
- .find_instructions(row) ⇒ Object
- .sanitize(html) ⇒ Object
- .write_errors(attrs) ⇒ Object
Class Method Details
.find_description(row) ⇒ Object
16 17 18 19 |
# File 'lib/fb_error_machine/error_writer.rb', line 16 def self.find_description(row) dirty_html = row.tds.to_a[1].inner_html sanitize(dirty_html) end |
.find_error_code(row) ⇒ Object
12 13 14 |
# File 'lib/fb_error_machine/error_writer.rb', line 12 def self.find_error_code(row) sanitize(row.tds.first.inner_html) end |
.find_instructions(row) ⇒ Object
21 22 23 |
# File 'lib/fb_error_machine/error_writer.rb', line 21 def self.find_instructions(row) sanitize(row.tds[2].inner_html) end |
.sanitize(html) ⇒ Object
25 26 27 |
# File 'lib/fb_error_machine/error_writer.rb', line 25 def self.sanitize(html) Sanitize.fragment(html).strip.gsub("\n", "").gsub(" ", " ") end |
.write_errors(attrs) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/fb_error_machine/error_writer.rb', line 4 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 |