Class: Mindee::Product::FR::EnergyBill::EnergyBillV1Subscription

Inherits:
Mindee::Parsing::Standard::FeatureField show all
Includes:
Mindee::Parsing::Standard
Defined in:
lib/mindee/product/fr/energy_bill/energy_bill_v1_subscription.rb

Overview

The subscription details fee for the energy service.

Instance Attribute Summary collapse

Attributes inherited from Mindee::Parsing::Standard::AbstractField

#bounding_box, #confidence, #page_id, #polygon

Instance Method Summary collapse

Methods inherited from Mindee::Parsing::Standard::FeatureField

#format_for_display

Methods inherited from Mindee::Parsing::Standard::AbstractField

array_confidence, array_sum, float_to_string

Constructor Details

#initialize(prediction, page_id) ⇒ EnergyBillV1Subscription

Returns a new instance of EnergyBillV1Subscription.

Parameters:

  • prediction (Hash)
  • page_id (Integer, nil)


33
34
35
36
37
38
39
40
41
42
# File 'lib/mindee/product/fr/energy_bill/energy_bill_v1_subscription.rb', line 33

def initialize(prediction, page_id)
  super(prediction, page_id)
  @description = prediction['description']
  @end_date = prediction['end_date']
  @start_date = prediction['start_date']
  @tax_rate = prediction['tax_rate']
  @total = prediction['total']
  @unit_price = prediction['unit_price']
  @page_id = page_id
end

Instance Attribute Details

#descriptionString (readonly)

Description or details of the subscription.

Returns:

  • (String)


14
15
16
# File 'lib/mindee/product/fr/energy_bill/energy_bill_v1_subscription.rb', line 14

def description
  @description
end

#end_dateString (readonly)

The end date of the subscription.

Returns:

  • (String)


17
18
19
# File 'lib/mindee/product/fr/energy_bill/energy_bill_v1_subscription.rb', line 17

def end_date
  @end_date
end

#start_dateString (readonly)

The start date of the subscription.

Returns:

  • (String)


20
21
22
# File 'lib/mindee/product/fr/energy_bill/energy_bill_v1_subscription.rb', line 20

def start_date
  @start_date
end

#tax_rateFloat (readonly)

The rate of tax applied to the total cost.

Returns:

  • (Float)


23
24
25
# File 'lib/mindee/product/fr/energy_bill/energy_bill_v1_subscription.rb', line 23

def tax_rate
  @tax_rate
end

#totalFloat (readonly)

The total cost of subscription.

Returns:

  • (Float)


26
27
28
# File 'lib/mindee/product/fr/energy_bill/energy_bill_v1_subscription.rb', line 26

def total
  @total
end

#unit_priceFloat (readonly)

The price per unit of subscription.

Returns:

  • (Float)


29
30
31
# File 'lib/mindee/product/fr/energy_bill/energy_bill_v1_subscription.rb', line 29

def unit_price
  @unit_price
end

Instance Method Details

#printable_valuesHash

Returns:

  • (Hash)


45
46
47
48
49
50
51
52
53
54
# File 'lib/mindee/product/fr/energy_bill/energy_bill_v1_subscription.rb', line 45

def printable_values
  printable = {}
  printable[:description] = format_for_display(@description)
  printable[:end_date] = format_for_display(@end_date)
  printable[:start_date] = format_for_display(@start_date)
  printable[:tax_rate] = @tax_rate.nil? ? '' : Field.float_to_string(@tax_rate)
  printable[:total] = @total.nil? ? '' : Field.float_to_string(@total)
  printable[:unit_price] = @unit_price.nil? ? '' : Field.float_to_string(@unit_price)
  printable
end

#table_printable_valuesHash

Returns:

  • (Hash)


57
58
59
60
61
62
63
64
65
66
# File 'lib/mindee/product/fr/energy_bill/energy_bill_v1_subscription.rb', line 57

def table_printable_values
  printable = {}
  printable[:description] = format_for_display(@description, 36)
  printable[:end_date] = format_for_display(@end_date, 10)
  printable[:start_date] = format_for_display(@start_date, nil)
  printable[:tax_rate] = @tax_rate.nil? ? '' : Field.float_to_string(@tax_rate)
  printable[:total] = @total.nil? ? '' : Field.float_to_string(@total)
  printable[:unit_price] = @unit_price.nil? ? '' : Field.float_to_string(@unit_price)
  printable
end

#to_sString

Returns:

  • (String)


82
83
84
85
86
87
88
89
90
91
92
# File 'lib/mindee/product/fr/energy_bill/energy_bill_v1_subscription.rb', line 82

def to_s
  printable = printable_values
  out_str = String.new
  out_str << "\n  :Description: #{printable[:description]}"
  out_str << "\n  :End Date: #{printable[:end_date]}"
  out_str << "\n  :Start Date: #{printable[:start_date]}"
  out_str << "\n  :Tax Rate: #{printable[:tax_rate]}"
  out_str << "\n  :Total: #{printable[:total]}"
  out_str << "\n  :Unit Price: #{printable[:unit_price]}"
  out_str
end

#to_table_lineString

Returns:

  • (String)


69
70
71
72
73
74
75
76
77
78
79
# File 'lib/mindee/product/fr/energy_bill/energy_bill_v1_subscription.rb', line 69

def to_table_line
  printable = table_printable_values
  out_str = String.new
  out_str << format('| %- 37s', printable[:description])
  out_str << format('| %- 11s', printable[:end_date])
  out_str << format('| %- 11s', printable[:start_date])
  out_str << format('| %- 9s', printable[:tax_rate])
  out_str << format('| %- 10s', printable[:total])
  out_str << format('| %- 11s', printable[:unit_price])
  out_str << '|'
end