Class: SimpleInlineTextAnnotation::Denotation
- Inherits:
-
Object
- Object
- SimpleInlineTextAnnotation::Denotation
- Defined in:
- lib/simple_inline_text_annotation/denotation.rb
Instance Attribute Summary collapse
-
#begin_pos ⇒ Object
readonly
Returns the value of attribute begin_pos.
-
#end_pos ⇒ Object
readonly
Returns the value of attribute end_pos.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#obj ⇒ Object
readonly
Returns the value of attribute obj.
Instance Method Summary collapse
- #boundary_crossing?(other) ⇒ Boolean
-
#initialize(begin_pos, end_pos, obj, id = nil) ⇒ Denotation
constructor
A new instance of Denotation.
- #nested_within?(other) ⇒ Boolean
- #out_of_bounds?(text_length) ⇒ Boolean
- #position_invalid? ⇒ Boolean
- #position_negative? ⇒ Boolean
- #position_not_integer? ⇒ Boolean
- #span ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(begin_pos, end_pos, obj, id = nil) ⇒ Denotation
Returns a new instance of Denotation.
10 11 12 13 14 15 |
# File 'lib/simple_inline_text_annotation/denotation.rb', line 10 def initialize(begin_pos, end_pos, obj, id = nil) @begin_pos = begin_pos @end_pos = end_pos @obj = obj @id = id end |
Instance Attribute Details
#begin_pos ⇒ Object (readonly)
Returns the value of attribute begin_pos.
8 9 10 |
# File 'lib/simple_inline_text_annotation/denotation.rb', line 8 def begin_pos @begin_pos end |
#end_pos ⇒ Object (readonly)
Returns the value of attribute end_pos.
8 9 10 |
# File 'lib/simple_inline_text_annotation/denotation.rb', line 8 def end_pos @end_pos end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/simple_inline_text_annotation/denotation.rb', line 8 def id @id end |
#obj ⇒ Object (readonly)
Returns the value of attribute obj.
8 9 10 |
# File 'lib/simple_inline_text_annotation/denotation.rb', line 8 def obj @obj end |
Instance Method Details
#boundary_crossing?(other) ⇒ Boolean
45 46 47 48 49 50 |
# File 'lib/simple_inline_text_annotation/denotation.rb', line 45 def boundary_crossing?(other) starts_inside_other = @begin_pos > other.begin_pos && @begin_pos < other.end_pos ends_inside_other = @end_pos > other.begin_pos && @end_pos < other.end_pos starts_inside_other || ends_inside_other end |
#nested_within?(other) ⇒ Boolean
25 26 27 |
# File 'lib/simple_inline_text_annotation/denotation.rb', line 25 def nested_within?(other) other.begin_pos <= @begin_pos && @end_pos <= other.end_pos end |
#out_of_bounds?(text_length) ⇒ Boolean
41 42 43 |
# File 'lib/simple_inline_text_annotation/denotation.rb', line 41 def out_of_bounds?(text_length) @begin_pos >= text_length || @end_pos > text_length end |
#position_invalid? ⇒ Boolean
37 38 39 |
# File 'lib/simple_inline_text_annotation/denotation.rb', line 37 def position_invalid? @begin_pos > @end_pos end |
#position_negative? ⇒ Boolean
33 34 35 |
# File 'lib/simple_inline_text_annotation/denotation.rb', line 33 def position_negative? @begin_pos.negative? || @end_pos.negative? end |
#position_not_integer? ⇒ Boolean
29 30 31 |
# File 'lib/simple_inline_text_annotation/denotation.rb', line 29 def position_not_integer? !(@begin_pos.is_a?(Integer) && @end_pos.is_a?(Integer)) end |
#span ⇒ Object
17 18 19 |
# File 'lib/simple_inline_text_annotation/denotation.rb', line 17 def span { begin: @begin_pos, end: @end_pos } end |
#to_h ⇒ Object
21 22 23 |
# File 'lib/simple_inline_text_annotation/denotation.rb', line 21 def to_h { id: @id, span: span, obj: @obj }.compact end |