Class: Hippo::TransactionSets::RepeatingComponent
Instance Method Summary
collapse
#pretty_print, #to_pretty_string
#to_pdf
#to_html
Constructor Details
#initialize(component_entry, parent) ⇒ RepeatingComponent
Returns a new instance of RepeatingComponent.
7
8
9
10
|
# File 'lib/hippo/transaction_sets/repeating_component.rb', line 7
def initialize(component_entry, parent)
@component_entry = component_entry
@parent = parent
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
42
43
44
45
46
|
# File 'lib/hippo/transaction_sets/repeating_component.rb', line 42
def method_missing(method_name, *args, &block)
build if self.length == 0
self.first.send(method_name, *args, &block)
end
|
Instance Method Details
#ancestors ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/hippo/transaction_sets/repeating_component.rb', line 34
def ancestors
if parent
parent.ancestors.flatten
else
[]
end
end
|
#build {|component| ... } ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/hippo/transaction_sets/repeating_component.rb', line 12
def build
component = @component_entry.populate_component(@component_entry.klass.new(:parent => @parent))
push(component)
yield component if block_given?
component
end
|
#segment_count ⇒ Object
30
31
32
|
# File 'lib/hippo/transaction_sets/repeating_component.rb', line 30
def segment_count
segments.length
end
|
#segments ⇒ Object
24
25
26
27
28
|
# File 'lib/hippo/transaction_sets/repeating_component.rb', line 24
def segments
return [] unless self.length != 0
self.map(&:segments).flatten
end
|
#to_s ⇒ Object
20
21
22
|
# File 'lib/hippo/transaction_sets/repeating_component.rb', line 20
def to_s
self.map(&:to_s).join
end
|