Class: Fat::HtmlToTextFixture

Inherits:
Fit::ColumnFixture show all
Defined in:
lib/fat/html_to_text_fixture.rb

Constant Summary collapse

@@metadata =
{'html' => String}

Constants inherited from Fit::Fixture

Fit::Fixture::GRAY, Fit::Fixture::GREEN, Fit::Fixture::RED, Fit::Fixture::YELLOW

Instance Attribute Summary collapse

Attributes inherited from Fit::Fixture

#args, #counts, #listener, #summary

Instance Method Summary collapse

Methods inherited from Fit::ColumnFixture

#check, #do_cell, #do_row, #do_rows, #execute, #reset

Methods inherited from Fit::Fixture

camel, #check, #do_cell, #do_cells, #do_row, #do_rows, #do_table, #do_tables, #error, escape, #exception, #find_class, #fixture_name, #get_args_for_table, #get_linked_fixture_with_args, gray, #ignore, #info, #initialize, #interpret_following_tables, #interpret_tables, label, metadata, #parse, #right, #total_errors, #totals, #wrong

Constructor Details

This class inherits a constructor from Fit::Fixture

Instance Attribute Details

#html=(value) ⇒ Object (writeonly)

Sets the attribute html

Parameters:

  • value

    the value to set the attribute html to.



10
11
12
# File 'lib/fat/html_to_text_fixture.rb', line 10

def html=(value)
  @html = value
end

Instance Method Details

#escape_ascii(text) ⇒ Object



15
16
17
# File 'lib/fat/html_to_text_fixture.rb', line 15

def escape_ascii text
  text.gsub([0x0a].pack('U'), "\\n").gsub([0x0d].pack('U'), "\\r").gsub([0xa0].pack('U'), " ")
end

#textObject



11
12
13
14
# File 'lib/fat/html_to_text_fixture.rb', line 11

def text
  html = @html.gsub(/\\u00a0/, [0x00a0].pack('U'))
  escape_ascii(Fit::Parse.html_to_text(html))
end