Class: RGFA::SegmentInfo Private
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A segment or segment name plus an additional boolean attribute
This class shall not be initialized directly.
Direct Known Subclasses
Defined Under Namespace
Classes: InvalidAttributeError, InvalidSizeError
Class Method Summary collapse
-
.invert(attribute) ⇒ Symbol
private
The other attribute value.
Instance Method Summary collapse
-
#<=>(other) ⇒ Boolean
private
Compare the segment names and attributes of two instances.
-
#==(other) ⇒ Boolean
private
Compare the segment names and attributes of two instances.
-
#attribute ⇒ Symbol
private
The attribute.
-
#attribute=(value) ⇒ Symbol
private
Set the attribute.
-
#attribute_inverted ⇒ Symbol
private
The other possible value of the attribute.
-
#invert_attribute ⇒ RGFA::SegmentInfo
private
Same segment, inverted attribute.
-
#name ⇒ Symbol
private
The segment name.
-
#segment ⇒ Symbol, RGFA::Line::Segment
private
The segment instance or name.
-
#segment=(value) ⇒ Object
private
Set the segment.
-
#to_s ⇒ String
private
Name of the segment and attribute.
-
#to_sym ⇒ Symbol
private
Name of the segment and attribute.
-
#validate! ⇒ void
private
Check that the elements of the array are compatible with the definition.
Methods inherited from Array
#default_gfa_datatype, #rgfa_field_array?, #to_byte_array, #to_cigar, #to_cigar_operation, #to_gfa_field, #to_numeric_array, #to_oriented_segment, #to_rgfa, #to_rgfa_field_array, #to_rgfa_line, #to_segment_end, #validate_gfa_field!
Class Method Details
.invert(attribute) ⇒ Symbol
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the other attribute value.
70 71 72 73 74 75 76 77 |
# File 'lib/rgfa/segment_info.rb', line 70 def self.invert(attribute) i = self::ATTR.index(attribute.to_sym) if i.nil? raise RGFA::SegmentInfo::InvalidAttributeError, "Invalid attribute (#{self[1].inspect})" end return self::ATTR[i-1] end |
Instance Method Details
#<=>(other) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Compare the segment names and attributes of two instances
101 102 103 |
# File 'lib/rgfa/segment_info.rb', line 101 def <=>(other) to_s <=> other.to_segment_info(self.class).to_s end |
#==(other) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Compare the segment names and attributes of two instances
93 94 95 |
# File 'lib/rgfa/segment_info.rb', line 93 def ==(other) to_s == other.to_segment_info(self.class).to_s end |
#attribute ⇒ Symbol
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the attribute.
47 48 49 |
# File 'lib/rgfa/segment_info.rb', line 47 def attribute self[1] end |
#attribute=(value) ⇒ Symbol
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Set the attribute
54 55 56 |
# File 'lib/rgfa/segment_info.rb', line 54 def attribute=(value) self[1]=(value) end |
#attribute_inverted ⇒ Symbol
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the other possible value of the attribute.
59 60 61 |
# File 'lib/rgfa/segment_info.rb', line 59 def attribute_inverted self.class::ATTR[self.class::ATTR[0] == self[1] ? 1 : 0] end |
#invert_attribute ⇒ RGFA::SegmentInfo
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns same segment, inverted attribute.
64 65 66 |
# File 'lib/rgfa/segment_info.rb', line 64 def invert_attribute self.class.new([self[0], self.attribute_inverted]) end |
#name ⇒ Symbol
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the segment name.
42 43 44 |
# File 'lib/rgfa/segment_info.rb', line 42 def name self[0].kind_of?(RGFA::Line::Segment) ? self[0].name : self[0].to_sym end |
#segment ⇒ Symbol, RGFA::Line::Segment
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the segment instance or name.
30 31 32 |
# File 'lib/rgfa/segment_info.rb', line 30 def segment self[0] end |
#segment=(value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Set the segment
37 38 39 |
# File 'lib/rgfa/segment_info.rb', line 37 def segment=(value) self[0]=value end |
#to_s ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns name of the segment and attribute.
80 81 82 |
# File 'lib/rgfa/segment_info.rb', line 80 def to_s "#{name}#{attribute}" end |
#to_sym ⇒ Symbol
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns name of the segment and attribute.
85 86 87 |
# File 'lib/rgfa/segment_info.rb', line 85 def to_sym to_s.to_sym end |
#validate! ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Check that the elements of the array are compatible with the definition.
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rgfa/segment_info.rb', line 17 def validate! if size != 2 raise RGFA::SegmentInfo::InvalidSizeError, "Wrong n of elements, 2 expected (#{inspect})" end if !self.class::ATTR.include?(self[1]) raise RGFA::SegmentInfo::InvalidAttributeError, "Invalid attribute (#{self[1].inspect})" end return nil end |