Module: RemoteTable::Format::Textual
- Included in:
- Delimited, FixedWidth, HTML, XML
- Defined in:
- lib/remote_table/format/mixins/textual.rb
Constant Summary collapse
- USELESS_CHARACTERS =
[ '\xef\xbb\xbf', # UTF-8 byte order mark '\xc2\xad', # soft hyphen, often inserted by MS Office (html: ­) '\xad', # '\xa0' ]
Instance Method Summary collapse
- #crop_rows! ⇒ Object
- #cut_columns! ⇒ Object
-
#remove_useless_characters! ⇒ Object
‘xa0’.
- #skip_rows! ⇒ Object
Instance Method Details
#crop_rows! ⇒ Object
21 22 23 24 |
# File 'lib/remote_table/format/mixins/textual.rb', line 21 def crop_rows! return unless t.properties.crop ::RemoteTable.executor.bang t.local_file.path, "tail -n +#{::Escape.shell_single_word t.properties.crop.first.to_s} | head -n #{t.properties.crop.last - t.properties.crop.first + 1}" end |
#cut_columns! ⇒ Object
26 27 28 29 |
# File 'lib/remote_table/format/mixins/textual.rb', line 26 def cut_columns! return unless t.properties.cut ::RemoteTable.executor.bang t.local_file.path, "cut -c #{::Escape.shell_single_word t.properties.cut.to_s}" end |
#remove_useless_characters! ⇒ Object
‘xa0’
12 13 14 |
# File 'lib/remote_table/format/mixins/textual.rb', line 12 def remove_useless_characters! ::RemoteTable.executor.bang t.local_file.path, "perl -pe 's/#{USELESS_CHARACTERS.join '//g; s/'}//g'" end |
#skip_rows! ⇒ Object
16 17 18 19 |
# File 'lib/remote_table/format/mixins/textual.rb', line 16 def skip_rows! return unless t.properties.skip > 0 ::RemoteTable.executor.bang t.local_file.path, "tail -n +#{t.properties.skip + 1}" end |