Class: LexM::Sublemma

Inherits:
Object
  • Object
show all
Defined in:
lib/lexm/sublemma.rb

Overview

Represents a sublemma, which can be either a textual sublemma or a redirection

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text = nil, redirect = nil) ⇒ Sublemma

Initialize a new sublemma

Parameters:

  • text (String, nil) (defaults to: nil)

    the text of the sublemma (nil for pure redirections)

  • redirect (LemmaRedirect, nil) (defaults to: nil)

    redirection information (nil for normal sublemmas)



19
20
21
22
# File 'lib/lexm/sublemma.rb', line 19

def initialize(text = nil, redirect = nil)
    @text = text
    @redirect = redirect
end

Instance Attribute Details

#redirectObject

Returns the value of attribute redirect.



14
15
16
# File 'lib/lexm/sublemma.rb', line 14

def redirect
  @redirect
end

#textObject

Returns the value of attribute text.



14
15
16
# File 'lib/lexm/sublemma.rb', line 14

def text
  @text
end

Instance Method Details

#redirected?Boolean

Is this a pure redirection sublemma?

Returns:

  • (Boolean)

    true if this is a pure redirection with no text



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

def redirected?
    @text.nil? && !@redirect.nil?
end

#to_sString

Convert to string representation

Returns:

  • (String)

    the string representation of this sublemma



32
33
34
35
36
37
38
# File 'lib/lexm/sublemma.rb', line 32

def to_s
    if redirected?
        @redirect.to_s
    else
        @text
    end
end