Class: Bio::GFFbrowser::Helpers::Section
- Inherits:
-
Range
- Object
- Range
- Bio::GFFbrowser::Helpers::Section
- Defined in:
- lib/bio/db/gff/gffassemble.rb
Instance Attribute Summary collapse
-
#rec ⇒ Object
readonly
Returns the value of attribute rec.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(rec) ⇒ Section
constructor
A new instance of Section.
- #intersection(other) ⇒ Object (also: #&)
Constructor Details
#initialize(rec) ⇒ Section
Returns a new instance of Section.
90 91 92 93 |
# File 'lib/bio/db/gff/gffassemble.rb', line 90 def initialize rec super(rec.start,rec.end) @rec = rec end |
Instance Attribute Details
#rec ⇒ Object (readonly)
Returns the value of attribute rec.
89 90 91 |
# File 'lib/bio/db/gff/gffassemble.rb', line 89 def rec @rec end |
Instance Method Details
#<=>(other) ⇒ Object
103 104 105 |
# File 'lib/bio/db/gff/gffassemble.rb', line 103 def <=> other first <=> other.first end |
#intersection(other) ⇒ Object Also known as: &
94 95 96 97 98 99 100 101 |
# File 'lib/bio/db/gff/gffassemble.rb', line 94 def intersection(other) raise ArgumentError, 'value must be a Range' unless other.kind_of?(Range) min, max = first, exclude_end? ? max : last other_min, other_max = other.first, other.exclude_end? ? other.max : other.last new_min = self === other_min ? other_min : other === min ? min : nil new_max = self === other_max ? other_max : other === max ? max : nil new_min && new_max ? new_min..new_max : nil end |