Class: Stevedore::StevedoreCsvRow
- Inherits:
-
StevedoreBlob
- Object
- StevedoreBlob
- Stevedore::StevedoreCsvRow
- Defined in:
- lib/parsers/stevedore_csv_row.rb
Instance Attribute Summary collapse
-
#download_url ⇒ Object
Returns the value of attribute download_url.
-
#row_num ⇒ Object
Returns the value of attribute row_num.
-
#text ⇒ Object
Returns the value of attribute text.
-
#title ⇒ Object
Returns the value of attribute title.
-
#whole_row ⇒ Object
Returns the value of attribute whole_row.
Attributes inherited from StevedoreBlob
Instance Method Summary collapse
- #clean_text ⇒ Object
-
#initialize(title, text, row_num, download_url, whole_row = {}) ⇒ StevedoreCsvRow
constructor
A new instance of StevedoreCsvRow.
- #to_hash ⇒ Object
Methods inherited from StevedoreBlob
Constructor Details
#initialize(title, text, row_num, download_url, whole_row = {}) ⇒ StevedoreCsvRow
Returns a new instance of StevedoreCsvRow.
6 7 8 9 10 11 12 |
# File 'lib/parsers/stevedore_csv_row.rb', line 6 def initialize(title, text, row_num, download_url, whole_row={}) self.title = title || download_url self.text = text self.download_url = download_url self.whole_row = whole_row self.row_num = row_num end |
Instance Attribute Details
#download_url ⇒ Object
Returns the value of attribute download_url.
5 6 7 |
# File 'lib/parsers/stevedore_csv_row.rb', line 5 def download_url @download_url end |
#row_num ⇒ Object
Returns the value of attribute row_num.
5 6 7 |
# File 'lib/parsers/stevedore_csv_row.rb', line 5 def row_num @row_num end |
#text ⇒ Object
Returns the value of attribute text.
5 6 7 |
# File 'lib/parsers/stevedore_csv_row.rb', line 5 def text @text end |
#title ⇒ Object
Returns the value of attribute title.
5 6 7 |
# File 'lib/parsers/stevedore_csv_row.rb', line 5 def title @title end |
#whole_row ⇒ Object
Returns the value of attribute whole_row.
5 6 7 |
# File 'lib/parsers/stevedore_csv_row.rb', line 5 def whole_row @whole_row end |
Instance Method Details
#clean_text ⇒ Object
14 15 16 |
# File 'lib/parsers/stevedore_csv_row.rb', line 14 def clean_text @clean_text ||= text.gsub(/<\/?[^>]+>/, '') # removes all tags end |
#to_hash ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/parsers/stevedore_csv_row.rb', line 18 def to_hash { "sha1" => Digest::SHA1.hexdigest(download_url + row_num.to_s), "title" => title.to_s, "source_url" => download_url.to_s, "file" => { "title" => title.to_s, "file" => clean_text.to_s }, "analyzed" => { "body" => clean_text.to_s, "metadata" => { "Content-Type" => "text/plain" }.merge( whole_row.to_h ) }, "_updatedAt" => DateTime.now } end |