Class: HealthSeven::Message::MessageDef
Instance Method Summary
collapse
Methods inherited from SegmentDef
#dsl_off!, #initialize, #method_missing, #multiple?, #optional?, #rule_name, #seg_name
Instance Method Details
#_children_enum ⇒ Object
80
81
82
83
84
85
|
# File 'lib/health_seven/message.rb', line 80
def _children_enum
@segments.map do |s|
s.dsl_off!
s.rule_name
end
end
|
#optional ⇒ Object
87
88
89
90
91
|
# File 'lib/health_seven/message.rb', line 87
def optional
@optional ||= @segments.map do |s|
s.rule_name if s.optional?
end.compact
end
|
#required ⇒ Object
93
94
95
96
97
|
# File 'lib/health_seven/message.rb', line 93
def required
@reqired ||= @segments.map do |s|
s.rule_name unless s.optional?
end.compact
end
|
#to_gramar(gramar) ⇒ Object
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
# File 'lib/health_seven/message.rb', line 99
def to_gramar(gramar)
gramar.push <<-RULE
rule message
msh segment* "\\n" <HealthSeven::SegmentLiteral>
end
rule segment
#{_children_enum.join(" / ")}
end
rule delim
"#{13.chr}"
end
rule not_delim
[^#{13.chr}]
end
rule payload
not_delim+ <HealthSeven::FieldsLiteral>
end
rule msh
'MSH' payload delim <HealthSeven::SegmentLiteral>
end
RULE
@segments.each do |s|
s.to_gramar(gramar)
end
gramar
end
|