Class: Planik::Lohnausweis::Eintrag

Inherits:
Object
  • Object
show all
Defined in:
lib/lohnausweis/daten_eintrag.rb

Overview

Abstrakte Klasse für alle Einträge in den Tabellen des Lohnausweises Ein Eintrag hat vier mögliche Spalten: Name, Menge, Ansatz und Betrag, von denen aber der einte oder andere nil sein kann.

Direct Known Subclasses

Abzug, Fakt, IstStunden, Rechnung, Zulage

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, menge, ansatz, einheit = "Fr") ⇒ Eintrag

Returns a new instance of Eintrag.



12
13
14
# File 'lib/lohnausweis/daten_eintrag.rb', line 12

def initialize(name, menge, ansatz, einheit = "Fr")
  @name, @menge, @ansatz, @einheit= name, menge, ansatz, einheit
end

Instance Attribute Details

#ansatzObject (readonly)

Returns the value of attribute ansatz.



10
11
12
# File 'lib/lohnausweis/daten_eintrag.rb', line 10

def ansatz
  @ansatz
end

#einheitObject (readonly)

Returns the value of attribute einheit.



10
11
12
# File 'lib/lohnausweis/daten_eintrag.rb', line 10

def einheit
  @einheit
end

#mengeObject (readonly)

Returns the value of attribute menge.



10
11
12
# File 'lib/lohnausweis/daten_eintrag.rb', line 10

def menge
  @menge
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/lohnausweis/daten_eintrag.rb', line 10

def name
  @name
end

Instance Method Details

#ansatz_to_sObject

Default Wert ist nil



27
28
29
# File 'lib/lohnausweis/daten_eintrag.rb', line 27

def ansatz_to_s
  nil
end

#betragObject



16
17
18
# File 'lib/lohnausweis/daten_eintrag.rb', line 16

def betrag
  raise "implement in subclass"
end

#betrag_gerundet_to_sObject



31
32
33
# File 'lib/lohnausweis/daten_eintrag.rb', line 31

def betrag_gerundet_to_s
  value_gerundet_to_s betrag
end

#menge_to_sObject

Die Menge, gerundet auf zwei Kommastellen genau



21
22
23
24
# File 'lib/lohnausweis/daten_eintrag.rb', line 21

def menge_to_s
  return menge if menge.instance_of? String
  menge.nil? ? nil :format('%.2f', menge)
end