Class: Reji::Tax

Inherits:
Object
  • Object
show all
Defined in:
lib/reji/tax.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(amount, currency, tax_rate) ⇒ Tax

Returns a new instance of Tax.



5
6
7
8
9
# File 'lib/reji/tax.rb', line 5

def initialize(amount, currency, tax_rate)
  @amount = amount
  @currency = currency
  @tax_rate = tax_rate
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(key) ⇒ Object

Dynamically get values from the Stripe TaxRate.



33
34
35
# File 'lib/reji/tax.rb', line 33

def method_missing(key)
  @tax_rate[key]
end

Instance Attribute Details

#currencyObject (readonly)

Get the applied currency.



12
13
14
# File 'lib/reji/tax.rb', line 12

def currency
  @currency
end

#tax_rateObject (readonly)

Stripe::TaxRate



30
31
32
# File 'lib/reji/tax.rb', line 30

def tax_rate
  @tax_rate
end

Instance Method Details

#amountObject

Get the total tax that was paid (or will be paid).



15
16
17
# File 'lib/reji/tax.rb', line 15

def amount
  format_amount(@amount)
end

#inclusive?Boolean

Determine if the tax is inclusive or not.

Returns:

  • (Boolean)


25
26
27
# File 'lib/reji/tax.rb', line 25

def inclusive?
  @tax_rate.inclusive
end

#raw_amountObject

Get the raw total tax that was paid (or will be paid).



20
21
22
# File 'lib/reji/tax.rb', line 20

def raw_amount
  @amount
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/reji/tax.rb', line 37

def respond_to_missing?(method_name, include_private = false)
  super
end