Class: Mindee::Product::FR::EnergyBill::EnergyBillV1EnergyUsages
- Inherits:
-
Array
- Object
- Array
- Mindee::Product::FR::EnergyBill::EnergyBillV1EnergyUsages
- Defined in:
- lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_usages.rb
Overview
Details of energy consumption.
Instance Attribute Summary collapse
-
#entries ⇒ Array<EnergyBillV1EnergyUsage>
readonly
Entries.
Class Method Summary collapse
-
.line_items_separator(char) ⇒ String
Creates a line of rST table-compliant string separators.
Instance Method Summary collapse
-
#initialize(prediction, page_id) ⇒ EnergyBillV1EnergyUsages
constructor
A new instance of EnergyBillV1EnergyUsages.
- #to_s ⇒ String
Constructor Details
#initialize(prediction, page_id) ⇒ EnergyBillV1EnergyUsages
Returns a new instance of EnergyBillV1EnergyUsages.
22 23 24 25 26 27 |
# File 'lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_usages.rb', line 22 def initialize(prediction, page_id) entries = prediction.map do |entry| EnergyBill::EnergyBillV1EnergyUsage.new(entry, page_id) end super(entries) end |
Instance Attribute Details
#entries ⇒ Array<EnergyBillV1EnergyUsage> (readonly)
Entries.
18 19 20 |
# File 'lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_usages.rb', line 18 def entries @entries end |
Class Method Details
.line_items_separator(char) ⇒ String
Creates a line of rST table-compliant string separators.
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_usages.rb', line 32 def self.line_items_separator(char) out_str = String.new out_str << "+#{char * 13}" out_str << "+#{char * 38}" out_str << "+#{char * 12}" out_str << "+#{char * 12}" out_str << "+#{char * 10}" out_str << "+#{char * 11}" out_str << "+#{char * 17}" out_str << "+#{char * 12}" out_str end |
Instance Method Details
#to_s ⇒ String
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_usages.rb', line 46 def to_s return '' if empty? lines = map do |entry| "\n #{entry.to_table_line}\n#{self.class.line_items_separator('-')}" end.join out_str = String.new out_str << ("\n#{self.class.line_items_separator('-')}\n ") out_str << ' | Consumption' out_str << ' | Description ' out_str << ' | End Date ' out_str << ' | Start Date' out_str << ' | Tax Rate' out_str << ' | Total ' out_str << ' | Unit of Measure' out_str << ' | Unit Price' out_str << (" |\n#{self.class.line_items_separator('=')}") out_str + lines end |