Class: OpenNlp::Util::Span

Inherits:
Object
  • Object
show all
Includes:
JavaClass
Defined in:
lib/open_nlp/util/span.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from JavaClass

included

Constructor Details

#initialize(s, e) ⇒ Span

Returns a new instance of Span.



8
9
10
11
12
13
# File 'lib/open_nlp/util/span.rb', line 8

def initialize(s, e)
  fail ArgumentError, 's should be an integer' unless s.is_a?(Fixnum)
  fail ArgumentError, 'e should be an integer' unless e.is_a?(Fixnum)

  @j_instance = self.class.java_class.new(s, e)
end

Instance Attribute Details

#j_instanceObject (readonly)

Returns the value of attribute j_instance.



6
7
8
# File 'lib/open_nlp/util/span.rb', line 6

def j_instance
  @j_instance
end

Instance Method Details

#==(obj) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/open_nlp/util/span.rb', line 31

def ==(obj)
  return false unless obj.is_a?(self.class)

  [:start, :end, :type].each_with_object(true) do |method, acc|
    acc = acc && self.public_send(method) == obj.public_send(method)
  end
end

#endObject



19
20
21
# File 'lib/open_nlp/util/span.rb', line 19

def end
  j_instance.getEnd
end

#lengthObject



27
28
29
# File 'lib/open_nlp/util/span.rb', line 27

def length
  j_instance.length
end

#startObject



15
16
17
# File 'lib/open_nlp/util/span.rb', line 15

def start
  j_instance.getStart
end

#typeObject



23
24
25
# File 'lib/open_nlp/util/span.rb', line 23

def type
  j_instance.getType
end