Class: Dispersion::Annotation

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/dispersion/annotation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, location) ⇒ Annotation

Returns a new instance of Annotation.



7
8
9
10
# File 'lib/dispersion/annotation.rb', line 7

def initialize(type, location)
  @type = type
  @location = location
end

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



12
13
14
# File 'lib/dispersion/annotation.rb', line 12

def location
  @location
end

#typeObject (readonly)

Returns the value of attribute type.



12
13
14
# File 'lib/dispersion/annotation.rb', line 12

def type
  @type
end

Instance Method Details

#<=>(other) ⇒ Object



14
15
16
# File 'lib/dispersion/annotation.rb', line 14

def <=>(other)
  comparison_value <=> other.comparison_value
end

#comparison_valueObject



18
19
20
21
22
23
# File 'lib/dispersion/annotation.rb', line 18

def comparison_value
  [
    location,
    (type == :reset ? 0 : 1)
  ]
end

#to_aryObject



25
26
27
# File 'lib/dispersion/annotation.rb', line 25

def to_ary
  [type, location]
end