Class: Bio::GFFbrowser::Helpers::Section

Inherits:
Range
  • Object
show all
Defined in:
lib/bio/db/gff/gffsection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rec) ⇒ Section

Returns a new instance of Section.



8
9
10
11
# File 'lib/bio/db/gff/gffsection.rb', line 8

def initialize rec
  super(rec.start,rec.end)
  @rec = rec
end

Instance Attribute Details

#recObject (readonly)

Returns the value of attribute rec.



7
8
9
# File 'lib/bio/db/gff/gffsection.rb', line 7

def rec
  @rec
end

Instance Method Details

#<=>(other) ⇒ Object



21
22
23
# File 'lib/bio/db/gff/gffsection.rb', line 21

def <=> other
  first <=> other.first
end

#intersection(other) ⇒ Object Also known as: &

Raises:

  • (ArgumentError)


12
13
14
15
16
17
18
19
# File 'lib/bio/db/gff/gffsection.rb', line 12

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