Class: DICOM::Sequence
- Includes:
- Elemental, ElementalParent
- 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 ⇒ Integer
Computes a hash code for this object.
-
#initialize(tag, options = {}) ⇒ Sequence
constructor
Creates a Sequence instance.
-
#to_sequence ⇒ Sequence
Returns self.
Methods included from ElementalParent
Methods included from Elemental
#name_as_method, #parents, #set_parent, #stream, #top_parent
Methods inherited from Parent
#[], #add, #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, #parse, #print, #representation, #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 ⇒ Integer
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 |
#to_sequence ⇒ Sequence
Returns self.
81 82 83 |
# File 'lib/dicom/sequence.rb', line 81 def to_sequence self end |