Class: Orbacle::PositionRange

Inherits:
Struct
  • Object
show all
Defined in:
lib/orbacle.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#endObject

Returns the value of attribute end

Returns:

  • (Object)

    the current value of end



5
6
7
# File 'lib/orbacle.rb', line 5

def end
  @end
end

#startObject

Returns the value of attribute start

Returns:

  • (Object)

    the current value of start



5
6
7
# File 'lib/orbacle.rb', line 5

def start
  @start
end

Instance Method Details

#end_characterObject



42
43
44
# File 'lib/orbacle.rb', line 42

def end_character
  self.end.character
end

#end_lineObject



30
31
32
# File 'lib/orbacle.rb', line 30

def end_line
  self.end.line
end

#include_position?(position) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
10
11
12
13
14
15
16
# File 'lib/orbacle.rb', line 6

def include_position?(position)
  if (start_line+1..end_line-1).include?(position.line)
    true
  elsif start_line == position.line && end_line == position.line
    (start_character <= position.character) && (position.character <= end_character)
  elsif start_line == position.line
    start_character <= position.character
  elsif end_line == position.line
    end_character >= position.character
  end
end

#on_edges?(position) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/orbacle.rb', line 18

def on_edges?(position)
  on_left_edge?(position) || on_right_edge?(position)
end

#on_left_edge?(position) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/orbacle.rb', line 22

def on_left_edge?(position)
  position == self.start
end

#on_right_edge?(position) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/orbacle.rb', line 26

def on_right_edge?(position)
  position == self.end
end

#start_characterObject



38
39
40
# File 'lib/orbacle.rb', line 38

def start_character
  self.start.character
end

#start_lineObject



34
35
36
# File 'lib/orbacle.rb', line 34

def start_line
  self.start.line
end