Class: Hippo::TransactionSets::RepeatingComponent
Instance Method Summary
collapse
#to_pdf
#to_html
Constructor Details
#initialize(component_entry, parent) ⇒ RepeatingComponent
Returns a new instance of RepeatingComponent.
6
7
8
9
|
# File 'lib/hippo/transaction_sets/repeating_component.rb', line 6
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
41
42
43
44
45
|
# File 'lib/hippo/transaction_sets/repeating_component.rb', line 41
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
33
34
35
36
37
38
39
|
# File 'lib/hippo/transaction_sets/repeating_component.rb', line 33
def ancestors
if parent
parent.ancestors.flatten
else
[]
end
end
|
#build {|component| ... } ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/hippo/transaction_sets/repeating_component.rb', line 11
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
29
30
31
|
# File 'lib/hippo/transaction_sets/repeating_component.rb', line 29
def segment_count
segments.length
end
|
#segments ⇒ Object
23
24
25
26
27
|
# File 'lib/hippo/transaction_sets/repeating_component.rb', line 23
def segments
return [] unless self.length != 0
self.map(&:segments).flatten
end
|
#to_s ⇒ Object
19
20
21
|
# File 'lib/hippo/transaction_sets/repeating_component.rb', line 19
def to_s
self.map(&:to_s).join
end
|