Class: Header
- Inherits:
-
Object
- Object
- Header
- Defined in:
- lib/ruby_astm/header.rb
Instance Attribute Summary collapse
-
#machine_name ⇒ Object
Returns the value of attribute machine_name.
-
#patients ⇒ Object
Returns the value of attribute patients.
-
#queries ⇒ Object
Returns the value of attribute queries.
-
#response_sent ⇒ Object
Returns the value of attribute response_sent.
Instance Method Summary collapse
-
#build_responses ⇒ Object
used to respond to queries.
-
#commit ⇒ Object
pushes each patient into a redis list called "patients".
-
#initialize(args) ⇒ Header
constructor
A new instance of Header.
- #to_json ⇒ Object
Constructor Details
#initialize(args) ⇒ Header
Returns a new instance of Header.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/ruby_astm/header.rb', line 7 def initialize(args) if args[:line] line = args[:line] unless line.fields[4].empty? fields = line.fields[4].split(/\^/) self.machine_name = fields[0].strip end else super end self.patients = [] self.queries = [] self.response_sent = false end |
Instance Attribute Details
#machine_name ⇒ Object
Returns the value of attribute machine_name.
2 3 4 |
# File 'lib/ruby_astm/header.rb', line 2 def machine_name @machine_name end |
#patients ⇒ Object
Returns the value of attribute patients.
3 4 5 |
# File 'lib/ruby_astm/header.rb', line 3 def patients @patients end |
#queries ⇒ Object
Returns the value of attribute queries.
4 5 6 |
# File 'lib/ruby_astm/header.rb', line 4 def queries @queries end |
#response_sent ⇒ Object
Returns the value of attribute response_sent.
5 6 7 |
# File 'lib/ruby_astm/header.rb', line 5 def response_sent @response_sent end |
Instance Method Details
#build_responses ⇒ Object
used to respond to queries. @return response_to_query : response to the header query.
30 31 32 33 34 35 36 37 |
# File 'lib/ruby_astm/header.rb', line 30 def build_responses responses = self.queries.map {|query| header_response = "1H|\`^&||||||||||P|E 1394-97|#{Time.now.strftime("%Y%m%d%H%M%S")}\r" query.response = header_response + query.build_response query.response } responses end |
#commit ⇒ Object
pushes each patient into a redis list called "patients"
23 24 25 26 |
# File 'lib/ruby_astm/header.rb', line 23 def commit self.patients.map{|patient| $redis.lpush("patients",patient.to_json)} #puts JSON.pretty_generate(JSON.parse(self.to_json)) end |
#to_json ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/ruby_astm/header.rb', line 39 def to_json hash = {} self.instance_variables.each do |x| hash[x] = self.instance_variable_get x end return hash.to_json end |