Class: Centaman::Object::Extra
- Inherits:
-
Centaman::Object
- Object
- Centaman::Object
- Centaman::Object::Extra
- Defined in:
- lib/centaman/object/extra.rb
Instance Attribute Summary collapse
-
#quantity ⇒ Object
Returns the value of attribute quantity.
Instance Method Summary collapse
- #after_init(_args = {}) ⇒ Object
-
#attributes ⇒ Object
rubocop:disable Metrics/MethodLength.
- #calculate_price_before_tax ⇒ Object
- #description ⇒ Object
- #json ⇒ Object
- #price ⇒ Object
Methods inherited from Centaman::Object
#define_variables, #initialize
Constructor Details
This class inherits a constructor from Centaman::Object
Instance Attribute Details
#quantity ⇒ Object
Returns the value of attribute quantity.
3 4 5 |
# File 'lib/centaman/object/extra.rb', line 3 def quantity @quantity end |
Instance Method Details
#after_init(_args = {}) ⇒ Object
5 6 7 |
# File 'lib/centaman/object/extra.rb', line 5 def after_init(_args = {}) @quantity = 0 end |
#attributes ⇒ Object
rubocop:disable Metrics/MethodLength
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/centaman/object/extra.rb', line 36 def attributes [ Centaman::Attribute.new( centaman_key: 'ExtraId', app_key: :id, type: :integer ), Centaman::Attribute.new( centaman_key: 'ExtraDescription', app_key: :extra_description, type: :string ), Centaman::Attribute.new( centaman_key: 'ExtraPrice', app_key: :price_including_tax, type: :float ), Centaman::Attribute.new( centaman_key: 'DepositPercentage', app_key: :deposit_percentage, type: :float ), Centaman::Attribute.new( centaman_key: 'IsTaxInclusive', app_key: :tax_inclusive, type: :boolean ), Centaman::Attribute.new( centaman_key: 'TaxPercentage', app_key: :tax_percentage, type: :float ) ] end |
#calculate_price_before_tax ⇒ Object
13 14 15 16 |
# File 'lib/centaman/object/extra.rb', line 13 def calculate_price_before_tax p = price_including_tax / (1 + tax_percentage / 100) p.round(2) end |
#description ⇒ Object
30 31 32 33 |
# File 'lib/centaman/object/extra.rb', line 30 def description @extra_description.gsub!('Bar Package Cocktail Cruises', 'Bar Package') @description = @extra_description end |
#json ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/centaman/object/extra.rb', line 18 def json { id: id, description: description, quantity: quantity, price: price, deposit_percentage: deposit_percentage, tax_inclusive: tax_inclusive, tax_percentage: tax_percentage } end |
#price ⇒ Object
9 10 11 |
# File 'lib/centaman/object/extra.rb', line 9 def price @price ||= tax_inclusive ? calculate_price_before_tax : price_including_tax end |