Class: Hbci::ElementGroup

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/hbci/element_group.rb

Direct Known Subclasses

Hbci::ElementGroups::Address2, Hbci::ElementGroups::AllowedGV, Hbci::ElementGroups::Aussetzung1, Hbci::ElementGroups::Aussetzung2, Hbci::ElementGroups::Aussetzung3, Hbci::ElementGroups::BTG, Hbci::ElementGroups::Berechtigter1, Hbci::ElementGroups::Berechtigter2, Hbci::ElementGroups::Cert, Hbci::ElementGroups::ChallengeValidity, Hbci::ElementGroups::CommParam, Hbci::ElementGroups::DauerDetails, Hbci::ElementGroups::FestCond1, Hbci::ElementGroups::FestCond2, Hbci::ElementGroups::FestCondVersion, Hbci::ElementGroups::Info, Hbci::ElementGroups::InfoInfo, Hbci::ElementGroups::KIK, Hbci::ElementGroups::KLimit, Hbci::ElementGroups::KTO, Hbci::ElementGroups::KTV2, Hbci::ElementGroups::KTV3, Hbci::ElementGroups::KTVInt, Hbci::ElementGroups::KTVZVInt, Hbci::ElementGroups::KeyName, Hbci::ElementGroups::MsgRef, Hbci::ElementGroups::ParCustomMsg, Hbci::ElementGroups::ParDauerDel, Hbci::ElementGroups::ParDauerEdit, Hbci::ElementGroups::ParDauerNew, Hbci::ElementGroups::ParDauerSEPADel, Hbci::ElementGroups::ParDauerSEPAEdit, Hbci::ElementGroups::ParDauerSEPANew, Hbci::ElementGroups::ParFestCondList, Hbci::ElementGroups::ParFestNew1, Hbci::ElementGroups::ParFestNew2, Hbci::ElementGroups::ParKUmsNew1, Hbci::ElementGroups::ParKUmsNew2, Hbci::ElementGroups::ParKUmsZeit1, Hbci::ElementGroups::ParKUmsZeit2, Hbci::ElementGroups::ParKontoauszug, Hbci::ElementGroups::ParLast, Hbci::ElementGroups::ParLastObjection, Hbci::ElementGroups::ParOrderHistory, Hbci::ElementGroups::ParPinTan2, Hbci::ElementGroups::ParSEPAInfo, Hbci::ElementGroups::ParSammelLast, Hbci::ElementGroups::ParSammelLastB2BSEPA, Hbci::ElementGroups::ParSammelLastCOR1SEPA, Hbci::ElementGroups::ParSammelLastSEPA, Hbci::ElementGroups::ParSammelUeb, Hbci::ElementGroups::ParSammelUebSEPA, Hbci::ElementGroups::ParTAN2Step1, Hbci::ElementGroups::ParTAN2Step2, Hbci::ElementGroups::ParTAN2Step3, Hbci::ElementGroups::ParTAN2Step4, Hbci::ElementGroups::ParTAN2Step5, Hbci::ElementGroups::ParTermSammelLast, Hbci::ElementGroups::ParTermSammelLastList, Hbci::ElementGroups::ParTermSammelUeb, Hbci::ElementGroups::ParTermSammelUebList, Hbci::ElementGroups::ParTermSepaB2B, Hbci::ElementGroups::ParTermSepaCOR1, Hbci::ElementGroups::ParTermSepaEinzelLast, Hbci::ElementGroups::ParTermUeb, Hbci::ElementGroups::ParTermUebEdit, Hbci::ElementGroups::ParTermUebList, Hbci::ElementGroups::ParTermUebSEPA, Hbci::ElementGroups::ParTermUebSEPADel, Hbci::ElementGroups::ParTermUebSEPAEdit, Hbci::ElementGroups::ParTermUebSEPAList, Hbci::ElementGroups::ParUeb, Hbci::ElementGroups::ParUebForeign, Hbci::ElementGroups::ParUmb, Hbci::ElementGroups::ParUmbSepa, Hbci::ElementGroups::ParVormerkposten, Hbci::ElementGroups::ParWPDepotList1, Hbci::ElementGroups::ParWPDepotList2, Hbci::ElementGroups::ParWPDepotUms, Hbci::ElementGroups::ParWPInfoList, Hbci::ElementGroups::ParWPKursList1, Hbci::ElementGroups::ParWPKursList2, Hbci::ElementGroups::ParWPRefList, Hbci::ElementGroups::ParWPStammList, Hbci::ElementGroups::Prolong, Hbci::ElementGroups::PubKey, Hbci::ElementGroups::RetVal, Hbci::ElementGroups::Saldo, Hbci::ElementGroups::Saldo2, Hbci::ElementGroups::SecTimestamp, Hbci::ElementGroups::SegmentHead, Hbci::ElementGroups::SuppCompMethods, Hbci::ElementGroups::SuppLangs, Hbci::ElementGroups::SuppSecMethods, Hbci::ElementGroups::SuppVersions, Hbci::ElementGroups::TANInfo, Hbci::ElementGroups::TANMediaInfo1, Hbci::ElementGroups::TANMediaInfo2, Hbci::ElementGroups::TANMediaInfo3, Hbci::ElementGroups::TANMediaInfo4, Hbci::ElementGroups::TimeRange, Hbci::ElementGroups::Timestamp, Hbci::ElementGroups::Unknown, Hbci::ElementGroups::Usage1, Hbci::ElementGroups::Usage2, Hbci::ElementGroups::Usage3, Hbci::ElementGroups::WPBInfo1, Hbci::ElementGroups::WPBInfo2, Hbci::ElementGroups::WPBKurs, Hbci::ElementGroups::WPKursData, Hbci::ElementGroups::WPRef, Hbci::ElementGroups::WPStammAktien, Hbci::ElementGroups::WPStammFonds, Hbci::ElementGroups::WPStammOptions, Hbci::ElementGroups::WPStammRenten, Hbci::ElementGroups::WPZinsTermine

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeElementGroup

Returns a new instance of ElementGroup.



39
40
41
42
43
44
# File 'lib/hbci/element_group.rb', line 39

def initialize
  @defined_elements = []
  @elements = []

  define_elements
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object (private)



62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/hbci/element_group.rb', line 62

def method_missing(name, *args)
  potential_element_name = name.to_s.split('=').first.to_sym
  is_writer = (name[-1..-1] == '=')

  index = index_for_element(potential_element_name)
  if index
    return set_element(potential_element_name, args.first) if is_writer && args.count == 1

    return get_element(potential_element_name)
  end

  super
end

Instance Attribute Details

#defined_elementsObject

Returns the value of attribute defined_elements.



9
10
11
# File 'lib/hbci/element_group.rb', line 9

def defined_elements
  @defined_elements
end

#elementsObject

Returns the value of attribute elements.



8
9
10
# File 'lib/hbci/element_group.rb', line 8

def elements
  @elements
end

Class Method Details

.element(name, definition = {}) ⇒ Object



15
16
17
# File 'lib/hbci/element_group.rb', line 15

def self.element(name, definition = {})
  elements_to_be_defined << definition.merge(name: name)
end

.elements_to_be_definedObject



11
12
13
# File 'lib/hbci/element_group.rb', line 11

def self.elements_to_be_defined
  @elements_to_be_defined ||= []
end

Instance Method Details

#define_element(definition) ⇒ Object



27
28
29
30
# File 'lib/hbci/element_group.rb', line 27

def define_element(definition)
  defined_elements << definition
  apply_element_default(definition)
end

#define_elementsObject



23
24
25
# File 'lib/hbci/element_group.rb', line 23

def define_elements
  self.class.elements_to_be_defined.each { |el| define_element(el) }
end

#element(name, definition = {}) ⇒ Object



19
20
21
# File 'lib/hbci/element_group.rb', line 19

def element(name, definition = {})
  define_element(definition.merge(name: name))
end

#respond_to?(name, include_all = false) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
49
50
# File 'lib/hbci/element_group.rb', line 46

def respond_to?(name, include_all = false)
  potential_element_name = name.to_s.split('=').first.to_sym

  index_for_element(potential_element_name) || super
end

#to_sObject



32
33
34
35
36
37
# File 'lib/hbci/element_group.rb', line 32

def to_s
  element_strings = elements.each_with_index.map do |element, index|
    ElementUnparser.new(element, defined_elements[index][:type]).unparse
  end
  element_strings.join(':').gsub(/:*$/, '')
end