Class: DICOM::Sequence
- Includes:
- Elemental
- Defined in:
- lib/dicom/sequence.rb
Overview
The Sequence class handles information related to Sequence elements.
Instance Attribute Summary
Attributes included from Elemental
#bin, #length, #name, #parent, #tag, #vr
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
Checks for equality.
-
#hash ⇒ Fixnum
Computes a hash code for this object.
-
#initialize(tag, options = {}) ⇒ Sequence
constructor
Creates a Sequence instance.
-
#parse(bin, syntax) ⇒ Object
Loads data from an encoded DICOM string and creates items and elements which are linked to this instance.
-
#to_sequence ⇒ Sequence
Returns self.
Methods included from Elemental
#name_as_method, #parents, #set_parent, #stream, #top_parent
Methods inherited from Parent
#[], #add, #add_item, #children, #children?, #count, #count_all, #delete, #delete_children, #delete_group, #delete_private, #delete_retired, #each, #each_element, #each_item, #each_sequence, #each_tag, #elements, #elements?, #encode_children, #exists?, #group, #handle_print, #inspect, #is_parent?, #items, #items?, #length=, #max_lengths, #method_missing, #print, #reset_length, #respond_to?, #sequences, #sequences?, #to_hash, #to_json, #to_yaml, #value
Methods included from Logging
Constructor Details
#initialize(tag, options = {}) ⇒ Sequence
Private sequences are named as ‘Private’.
Non-private sequences that are not found in the dictionary are named as ‘Unknown’.
Creates a Sequence instance.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/dicom/sequence.rb', line 27 def initialize(tag, ={}) raise ArgumentError, "The supplied tag (#{tag}) is not valid. The tag must be a string of the form 'GGGG,EEEE'." unless tag.is_a?(String) && tag.tag? # Set common parent variables: initialize_parent # Set instance variables: @tag = tag.upcase @value = nil @bin = nil # We may beed to retrieve name and vr from the library: if [:name] and [:vr] @name = [:name] @vr = [:vr] else name, vr = LIBRARY.name_and_vr(tag) @name = [:name] || name @vr = [:vr] || 'SQ' end @length = [:length] || -1 if [:parent] @parent = [:parent] @parent.add(self, :no_follow => true) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class DICOM::Parent
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
Checks for equality.
Other and self are considered equivalent if they are of compatible types and their attributes are equivalent.
59 60 61 62 63 |
# File 'lib/dicom/sequence.rb', line 59 def ==(other) if other.respond_to?(:to_sequence) other.send(:state) == state end end |
#hash ⇒ Fixnum
Two objects with the same attributes will have the same hash code.
Computes a hash code for this object.
73 74 75 |
# File 'lib/dicom/sequence.rb', line 73 def hash state.hash end |
#parse(bin, syntax) ⇒ Object
Loads data from an encoded DICOM string and creates items and elements which are linked to this instance.
83 84 85 86 87 |
# File 'lib/dicom/sequence.rb', line 83 def parse(bin, syntax) raise ArgumentError, "Invalid argument 'bin'. Expected String, got #{bin.class}." unless bin.is_a?(String) raise ArgumentError, "Invalid argument 'syntax'. Expected String, got #{syntax.class}." unless syntax.is_a?(String) read(bin, signature=false, :syntax => syntax) end |
#to_sequence ⇒ Sequence
Returns self.
93 94 95 |
# File 'lib/dicom/sequence.rb', line 93 def to_sequence self end |