Class: ReceiptDataExtraction::Specific_data
- Inherits:
-
Object
- Object
- ReceiptDataExtraction::Specific_data
- Defined in:
- lib/receipt_data_extraction.rb
Class Method Summary collapse
- .get_address(text) ⇒ Object
- .get_data_before_total(text) ⇒ Object
- .get_date(text) ⇒ Object
- .get_products(text) ⇒ Object
- .get_shop_name(text) ⇒ Object
- .get_total(text) ⇒ Object
Instance Method Summary collapse
-
#remove_neg_values(text) ⇒ Object
remove all discounts/cancellations.
Class Method Details
.get_address(text) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/receipt_data_extraction.rb', line 28 def self.get_address(text) address = text.split(Name_reg)[1] text = text.sub!(address,"") address2 = text.split(Name_reg)[2] address = address + " " + address2 return address end |
.get_data_before_total(text) ⇒ Object
67 68 69 70 |
# File 'lib/receipt_data_extraction.rb', line 67 def self.get_data_before_total(text) text = text.split(Clean_text)[0] return text end |
.get_date(text) ⇒ Object
36 37 38 39 40 |
# File 'lib/receipt_data_extraction.rb', line 36 def self.get_date(text) date = text.match(Date_reg) date = Date.parse(date[0]).strftime("%d/%m/%Y") return date end |
.get_products(text) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/receipt_data_extraction.rb', line 52 def self.get_products(text) text.scan(Product_reg) do |qtde, name_product, price, price_total| if (name_product != "") && (price != nil) if qtde != nil puts "-qtde: #{qtde}" end puts "-name_product: #{name_product}" puts "Price: #{price}" if price_total != nil puts "Price_Total: #{price_total}" end end end end |
.get_shop_name(text) ⇒ Object
22 23 24 25 26 |
# File 'lib/receipt_data_extraction.rb', line 22 def self.get_shop_name(text) shop_name = text.split(Name_reg).first text = text.sub!(shop_name, "") return shop_name end |
.get_total(text) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/receipt_data_extraction.rb', line 42 def self.get_total(text) total = 0.00 text.scan(Total_reg) do |amount| if total < amount[0].to_f total = amount[0].to_f end end return total end |
Instance Method Details
#remove_neg_values(text) ⇒ Object
remove all discounts/cancellations
73 74 75 76 |
# File 'lib/receipt_data_extraction.rb', line 73 def remove_neg_values(text) text = text.gsub(Negative_values, "") return text end |