Class: Xrechnung::Currency

Inherits:
Struct
  • Object
show all
Defined in:
lib/xrechnung/currency.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#currency_idObject

Returns the value of attribute currency_id



5
6
7
# File 'lib/xrechnung/currency.rb', line 5

def currency_id
  @currency_id
end

#valueObject

Returns the value of attribute value



5
6
7
# File 'lib/xrechnung/currency.rb', line 5

def value
  @value
end

Class Method Details

.EUR(value) ⇒ Object

Raises:

  • (ArgumentError)


16
17
18
19
20
# File 'lib/xrechnung/currency.rb', line 16

def EUR(value)
  raise ArgumentError, "value must respond to :to_d" unless value.respond_to? :to_d

  Currency.new(currency_id: "EUR", value: value.to_d)
end

Instance Method Details

#value_to_sObject



6
7
8
# File 'lib/xrechnung/currency.rb', line 6

def value_to_s
  format("%0.2f", value)
end

#xml_argsObject



10
11
12
# File 'lib/xrechnung/currency.rb', line 10

def xml_args
  [value_to_s, { currencyID: currency_id }]
end