Class: Orbacle::PositionRange
- Inherits:
-
Struct
- Object
- Struct
- Orbacle::PositionRange
- Defined in:
- lib/orbacle.rb
Instance Attribute Summary collapse
-
#end ⇒ Object
Returns the value of attribute end.
-
#start ⇒ Object
Returns the value of attribute start.
Instance Method Summary collapse
- #end_character ⇒ Object
- #end_line ⇒ Object
- #include_position?(position) ⇒ Boolean
- #on_edges?(position) ⇒ Boolean
- #on_left_edge?(position) ⇒ Boolean
- #on_right_edge?(position) ⇒ Boolean
- #start_character ⇒ Object
- #start_line ⇒ Object
Instance Attribute Details
#end ⇒ Object
Returns the value of attribute end
5 6 7 |
# File 'lib/orbacle.rb', line 5 def end @end end |
#start ⇒ Object
Returns the value of attribute start
5 6 7 |
# File 'lib/orbacle.rb', line 5 def start @start end |
Instance Method Details
#end_character ⇒ Object
42 43 44 |
# File 'lib/orbacle.rb', line 42 def end_character self.end.character end |
#end_line ⇒ Object
30 31 32 |
# File 'lib/orbacle.rb', line 30 def end_line self.end.line end |
#include_position?(position) ⇒ 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
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
22 23 24 |
# File 'lib/orbacle.rb', line 22 def on_left_edge?(position) position == self.start end |
#on_right_edge?(position) ⇒ Boolean
26 27 28 |
# File 'lib/orbacle.rb', line 26 def on_right_edge?(position) position == self.end end |
#start_character ⇒ Object
38 39 40 |
# File 'lib/orbacle.rb', line 38 def start_character self.start.character end |
#start_line ⇒ Object
34 35 36 |
# File 'lib/orbacle.rb', line 34 def start_line self.start.line end |