Class: Canopus::Selection

Inherits:
Data
  • Object
show all
Defined in:
lib/canopus/selection.rb,
sig/canopus.rbs

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#anchor ⇒ Object (readonly)

Returns the value of attribute anchor

Returns:

  • (Object) —

    the current value of anchor



4
5
6
# File 'lib/canopus/selection.rb', line 4

def anchor
  @anchor
end

#goal ⇒ Object (readonly)

Returns the value of attribute goal

Returns:

  • (Object) —

    the current value of goal



4
5
6
# File 'lib/canopus/selection.rb', line 4

def goal
  @goal
end

#head ⇒ Object (readonly)

Returns the value of attribute head

Returns:

  • (Object) —

    the current value of head



4
5
6
# File 'lib/canopus/selection.rb', line 4

def head
  @head
end

#id ⇒ Object (readonly)

Returns the value of attribute id

Returns:

  • (Object) —

    the current value of id



4
5
6
# File 'lib/canopus/selection.rb', line 4

def id
  @id
end

Class Method Details

.new ⇒ instance

Parameters:

  • id (Integer)
  • anchor (Integer)
  • head (Integer)
  • goal (Integer, nil)

Returns:

  • (instance)


23
# File 'sig/canopus.rbs', line 23

def self.new: (Integer id, Integer anchor, Integer head, Integer? goal) -> instance

Instance Method Details

#empty? ⇒ Boolean

Returns:

  • (Boolean)


8
# File 'lib/canopus/selection.rb', line 8

def empty? = anchor == head

#end ⇒ Integer

Returns:

  • (Integer)


6
# File 'lib/canopus/selection.rb', line 6

def end = [anchor, head].max

#range ⇒ Range[Integer]

Returns:

  • (Range[Integer])


7
# File 'lib/canopus/selection.rb', line 7

def range = self.start...self.end

#reversed? ⇒ Boolean

Returns:

  • (Boolean)


9
# File 'lib/canopus/selection.rb', line 9

def reversed? = head < anchor

#start ⇒ Integer

Returns:

  • (Integer)


5
# File 'lib/canopus/selection.rb', line 5

def start = [anchor, head].min